Mouse position -> time with segmented timeline?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
SomeAwesomeGuy
Posts: 8
Joined: Tue Jul 06, 2010 4:18 pm
antibot: No, of course not.

Mouse position -> time with segmented timeline?

Post by SomeAwesomeGuy » Tue Jul 06, 2010 4:37 pm

I have an XYPlot using a DateAxis for the domain axis. I would like to convert mouse coordinates to the corresponding time on the x-axis. This is usually pretty simple, and can be done by getting the screen data area, finding the mouse position in relation to this area, and then calculating the time with respect to the minimum and maximum axis dates. However, I am using a segmented timeline, which skips some periods of time, so this method won't work. Is there a more direct method of finding the x-axis value from the mouse's position?

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Mouse position -> time with segmented timeline?

Post by skunk » Tue Jul 06, 2010 5:41 pm

In my code I use the following

Code: Select all

double chartX = xyplot.getDomainAxis().java2DToValue(p.getX(), subplotArea, xyplot.getDomainAxisEdge());

SomeAwesomeGuy
Posts: 8
Joined: Tue Jul 06, 2010 4:18 pm
antibot: No, of course not.

Re: Mouse position -> time with segmented timeline?

Post by SomeAwesomeGuy » Tue Jul 06, 2010 6:01 pm

Skunk, you are awesome. Thank you.

Locked