Data table with legends in JfreeChart/Java
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开发者_C百科 source) tool to generate chart with data table ?
Thanks
alt text http://img153.imageshack.us/img153/4550/jfree.png
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.
精彩评论