JFreeChart- point clicked, clear/ reset Crosshair ?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
AjitPS
Posts: 49
Joined: Tue Oct 22, 2013 10:08 am
antibot: No, of course not.
Location: UK

JFreeChart- point clicked, clear/ reset Crosshair ?

Post by AjitPS » Mon Mar 03, 2014 3:22 pm

Hi,
I am using the XYLinechart in JFreeChart to generate a chart with multiple XYSeries on it. My chart has 3 XYSeries on it and I have coded my program to return and display the x, y values only for 1 of the Series. I use a ChartMouseListener to detect mouse clicks on the ChartPanel. Currently, if I click somewhere on the chart, the x, y crosshair co-ordinates for the click are returned via:

Code: Select all

double xAxisVal = plot.getDomainCrosshairValue();
double yAxisVal = plot.getRangeCrosshairValue();
If these values correspond to the x, y values for any point on a specific XYSeries, then those values are displayed along with some notification. For points on the other 2 series, nothing is displayed.
However, clicking on the chart where the other 2 series are still displays the Crosshairs (by default) on the chart. I want the ChartPanel to not show any visible crosshairs on the clicked point unless the click corresponds to a point on a specific Series.

Is there anyway to clear or re-set the Crosshair that gets displayed by default, i.e., is there a way to prevent the Crosshair from being shown on the chart unless a certain criteria is met or to clear it if we want ? Kindly let me know. Thanks.

Locked