How to get x axis and y axis value!?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

How to get x axis and y axis value!?

Post by khanhlv » Thu Aug 14, 2008 4:54 am

My problem is that: I want to get the value of x axis and y axis when i choose a point in the graph.

Normally i can use getDomainCrosshairValue() and getRangeCrosshairValue to get its value. But i want to get every point not only the points in dataset.

Can i get that information???
Thank you very much!

khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

Post by khanhlv » Thu Aug 14, 2008 8:28 am

Any one can help me!?
This function is very useful for getting the data of an area for further processing!

BR!

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 » Thu Aug 14, 2008 9:10 pm

MouseListenerDemo4.java has an example of this (source available for download with the JFreeChart Developer Guide).

Essentially you need to convert the mouse coordinates from screen space to chart drawing space (which means you'll need to take into account any scaling, if any, that the ChartPanel has done behind the scenes). Once you've done that, you just need the bounds of the data area (i.e. the area inside the axes), and the lower/upper bounds of the axes and you can convert from chart drawing coordinates (Java2D) into data coordinates.
David Gilbert
JFreeChart Project Leader

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

khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

Post by khanhlv » Fri Aug 15, 2008 2:49 am

Thank for your support!
I will try it!

BR!

Locked