JfreeChart/Java中带有图例的数据表 [英] Data table with legends in JfreeChart/Java
问题描述
我正在使用JFreeChart生成图像.我正在尝试创建如下的条形图.没有数据表,我就能成功创建它.我试图从jfreechar论坛中获取更多信息,并发现了此帖子.根据该帖子,JfreeChart不支持它.
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.
- jfreechart API仍不支持它吗?
- 如果可以,我是否可以使用任何其他图表(开源)工具来生成带有数据表的图表?
谢谢
替代文本http://img153.imageshack.us/img153/4550/jfree .png
推荐答案
我不知道这方面有什么新变化.一种简单的方法是依赖默认的CategoryToolTipGenerator
或根据需要对其进行自定义:
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()));
一种更雄心勃勃的方法是添加一个具有TableModel
的JTable
,可以访问图表的CategoryDataset
.最左边一列的TableCellRenderer
可能使用BarRenderer
的getSeriesPaint()
.此示例显示了一个自定义渲染器,该渲染器实现了Icon
界面进行绘制.
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.
这篇关于JfreeChart/Java中带有图例的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!