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!
How to get x axis and y axis value!?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
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.
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
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

