Manually Selecting Data Point/Cross Hairs

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
robdocmagic
Posts: 7
Joined: Wed May 17, 2006 12:46 pm

Manually Selecting Data Point/Cross Hairs

Post by robdocmagic » Wed May 17, 2006 12:51 pm

Hi,

I have a chart that has a bunch of monthly data in it.

I have added a ChartMouseListener so that when a user selects a point on a chart (and the crosshairs appear) I can determine the value, for example: 1/1/2001 with a value of 2.0.

Then when the user saves I store this selection.

However, when the user reopens the app I want to "Set" the crosshairs to be pointing back at this data point. I am not sure how to accomplish this and any ideas would be greatly appreciated.

Thanks.

(ps I bought the dev guide which is great, I just can't seem to figure this out).

robdocmagic
Posts: 7
Joined: Wed May 17, 2006 12:46 pm

Post by robdocmagic » Wed May 17, 2006 4:39 pm

Hi,

I think I am onto something but it does not seem to work (based on samples and looking at the source):

Code: Select all

        Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
        double x = dateAxis.dateToJava2D(new Date(/* a date value on the domain axis*/), dataArea, plot.getDomainAxisEdge());
        double y = indexAxis.valueToJava2D(/* a value on the range axis */, dataArea, plot.getRangeAxisEdge());

        chartPanel.setAnchor(new Point2D.Double(x, y)); // I extended Chart Panel as setAnchor was protected
        chart.setNotify(true);
Please let me know if anyone has any ideas.. thanks.

Locked