Trying to find out the dateset for the bar chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
blajevardi
Posts: 9
Joined: Tue Nov 21, 2006 2:19 am

Trying to find out the dateset for the bar chart

Post by blajevardi » Thu Sep 06, 2007 7:32 pm

I am interested to know how to find the dataset for specific bar once I click the mouse on the bar or move the mouse over it.
I believe the solution would good enough for bar chart and stacked bar chart.
I know I can define a mouse handler that get the event and register it with the chart itself by using addChartMouseListener. I could not figure out an easy way to know what bar was clicked. I looked into ScatterPlotDemo3, but I could not tweak it to use for bar chart.

Anybody out there to have a solution?

Thanks,

Brian

blajevardi
Posts: 9
Joined: Tue Nov 21, 2006 2:19 am

I found a dirty way!

Post by blajevardi » Fri Sep 07, 2007 12:14 am

In the mouse event handler, I can do the following:
public void mouseReleased(MouseEvent e) {
ChartPanel cp = (ChartPanel) e.getSource();
String str = cp.getToolTipText(e);
str = str.substring(str.indexOf(',') + 2, str.indexOf(')'));
System.out.println(str);
}
This would give me the domain value!

Locked