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
Trying to find out the dateset for the bar chart
-
- Posts: 9
- Joined: Tue Nov 21, 2006 2:19 am
-
- Posts: 9
- Joined: Tue Nov 21, 2006 2:19 am
I found a dirty way!
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!
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!