Reputation: 639
I have created an application that creates bar graph based on inputs read from input file using JFreeChart, Now I want that when I point the mouse over a particular bar it shows the input responsible for that bar. How to do this ?
my code to print bar chart-
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);
}
Upvotes: 1
Views: 959