Data table with legends in JfreeChart/Java

谁说胖子不能爱 提交于 2019-12-11 07:26:50

问题


I am using JFreeChart to generate images. I am trying to create barchart like below. I am able to create it successfully without data table. I tried to get more information from the jfreechar forums and found this post. According to the post , its not supported by JfreeChart.

  • Is it still not supported by jfreechart API ?
  • If yes, can I use any other charting (open source) tool to generate chart with data table ?

Thanks

alt text http://img153.imageshack.us/img153/4550/jfree.png


回答1:


I'm not aware of a anything new in this area. One simple approach is to rely on the default CategoryToolTipGenerator or customize it as desired:

BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(
    "({0}, {1}) = {2}", NumberFormat.getInstance()));

A more ambitious approach would be to add a JTable having a TableModel with access to your chart's CategoryDataset. A TableCellRenderer for the leftmost column might use the BarRenderer's getSeriesPaint(). This example shows a custom renderer that implements the Icon interface to do the drawing.



来源:https://stackoverflow.com/questions/2873788/data-table-with-legends-in-jfreechart-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!