Bar Chart question

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
dmacleod
Posts: 8
Joined: Fri Jun 29, 2007 4:48 pm
Location: Florida, USA

Bar Chart question

Post by dmacleod » Tue Jul 31, 2007 3:37 pm

I have a bar chart, and would like to know when a user clicks on a bar then get the label for that bar. Is there a way to do this?

thanks

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Jul 31, 2007 3:42 pm

Add a ChartMouseListener to the ChartPanel.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

dmacleod
Posts: 8
Joined: Fri Jun 29, 2007 4:48 pm
Location: Florida, USA

Post by dmacleod » Tue Jul 31, 2007 3:47 pm

If I add a ChartMouseListener, do I have to calculate x y coordinates or does the chart know what bar the mouse is over? Do you have an example of this, I couldn't find anything in the JFreeChart developers guide.

thanks

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Jul 31, 2007 3:59 pm

Take a look at MouseListenerDemo2.java.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

dmacleod
Posts: 8
Joined: Fri Jun 29, 2007 4:48 pm
Location: Florida, USA

Post by dmacleod » Tue Jul 31, 2007 4:48 pm

thanks, the demo was a perfect example of what I want to do.

Thanks again

Locked