Getting plot value from mouse

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jas511
Posts: 6
Joined: Tue Sep 01, 2009 7:02 pm
antibot: No, of course not.

Getting plot value from mouse

Post by jas511 » Fri Oct 02, 2009 11:17 pm

Is there a way to get the x,y coordinates of the mouse on the plot from a ChartMouseEvent? Basically, I'm trying to show the x,y value on a label somewhere else based on where the mouse is. I only need to do this on mouse clicks.

thanks,
Jeff
Jeff Storey, Software Developer
http://jeffastorey.blogspot.com

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

Re: Getting plot value from mouse

Post by david.gilbert » Mon Oct 05, 2009 9:46 pm

One of the MouseListenerDemo programs does this calculation. You can use the java2dToValue() methods in the axis classes, passing in the dataArea used by the ChartPanel (bearing in mind that it might have been subjected to scaling before drawing on screen - see the getMin/MaxDrawingWidth/Height() methods in the ChartPanel class.
David Gilbert
JFreeChart Project Leader

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

Locked