问题
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