【发布时间】:2012-04-05 18:56:58
【问题描述】:
我创建了一个应用程序,该应用程序根据使用 JFreeChart 从输入文件读取的输入创建条形图,现在我希望当我将鼠标指向特定条形时,它会显示负责该条形的输入.如何做到这一点?
我打印条形图的代码-
public BarChart(double val[],String title) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for(int i=1;i<=val.length;i++){
dataset.setValue(val[i-1], "Execution Time(ms)",""+i);
}
JFreeChart chart = ChartFactory.createBarChart
("BarChart for "+title,"API calls", "Execution Time(ms)", dataset,
PlotOrientation.VERTICAL, false,true, false);
CategoryPlot p = chart.getCategoryPlot();
p.setRangeGridlinePaint(Color.red);
frame1=new ChartFrame("Bar Chart",chart);
final Rectangle s = WindowBound.getMaximumWindowBounds();
final Dimension f = frame1.getSize();
final int w = Math.max(s.width - f.width, 0);
final int h = Math.max(s.height - f.height, 0);
final int x = (int) (0.5 * w) + s.x;
final int y = (int) (0.5 * h) + s.y;
frame1.setBounds(x-300, y-300, f.width, f.height);
frame1.setIconImage(Toolkit.getDefaultToolkit().getImage("Images/Icon.jpg"));
frame1.setSize(600,600);
}
【问题讨论】:
-
您是否启用了工具提示?您是否尝试过自定义工具提示渲染器?请编辑您的问题,在sscce 中包含您描述的问题。
-
@trashgod - 添加了代码...nw 告诉我什么是工具提示渲染器,n 如何使用它..任何解释它的链接也可以。
标签: java jfreechart