0

I'm using jchart2D library to plot functions. I need to get cursor coordinates. That question was asked already here. When I add MouseMotionListener to Chart2D, it gives location of cursor in pixels (but not coordinates). getNearestPoint function also doesn't work because it finds Point which is in Trace

Community
  • 1
  • 1
lnk
  • 593
  • 2
  • 11
  • 27

1 Answers1

1

It's unlikely that you want to interpolate between points on the chart, as shown here. Instead, use a ChartMouseListener, as illustrated here and here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I guess it works for jfreechart library. But unfortunately I didn't find any analog of CharMouseListener in jchart2d. – lnk Feb 03 '14 at 14:55
  • Oops, sorry. You'll need to do linear interpolation, as shown [here](http://stackoverflow.com/a/2901472/230513). Are you using `net.sourceforge.chart2d.Chart2D` or `info.monitorenter.gui.chart.Chart2D`? – trashgod Feb 03 '14 at 15:40
  • I am using info.monitorenter.gui.chart.Chart2D. I can't figure out how your link can help me. – lnk Feb 03 '14 at 20:02
  • 1
    Ah, two different libraries; I've updated the [tag:jchart2d] tag. You'll have to [interpolate](http://en.wikipedia.org/wiki/Linear_interpolation) the mouse coordinates to derive model coordinates, and vice-versa. – trashgod Feb 03 '14 at 21:47
  • I see. For this I need location of the origin of axes. – lnk Feb 04 '14 at 14:22