Dataset-Values for MouseOver-Effect

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Mathias Haushofer
Posts: 25
Joined: Fri Mar 14, 2003 2:21 pm

Dataset-Values for MouseOver-Effect

Post by Mathias Haushofer » Fri Mar 14, 2003 3:04 pm

hi,

i would like to create a mouseOver-Effect which behaves likes this:

when the mouse enters my overlaid-area-plot, a vertical line shall be drawn at the position of the mouse
(i already found out, that this can be done via chartPanel.setHorizontalAxisTrace(true) )

AND

the current dataset-values of the plot at the point of the mouse-position should be displayed in detail below the plot.

how can i get access to the data dependent on the mouse-coordinates?
has anyone done something like this before?
or is there already a built-in feature of jfreechart which does this?
(i found nothing in the documentation so far :cry: )

thx for any help,

mathias

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 » Fri Mar 14, 2003 6:03 pm

Take a look at the way the getToolTipText(...) method in the ChartPanel class works to find the ChartEntity under the mouse pointer. In your own code, you could do the same thing, but check to see if the ChartEntity is an 'instanceof' XYItemEntity. If it is, you can query the series index and the item index. From there, you can get the data value straight from the dataset, and display it wherever you want it.

Regards,

Dave Gilbert

Locked