Label on crosshair : how to

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Ghurdyl
Posts: 6
Joined: Fri Apr 09, 2010 1:49 pm
antibot: No, of course not.

Label on crosshair : how to

Post by Ghurdyl » Fri Apr 09, 2010 2:30 pm

Hello,

I am new in the wonderful world of JFreeChart and wish to as more experienced users if the following is possible (and obviously how :D)

I have time lines showing for a given "task" when it has been planned, when is it's due date and when it has been realized, ...
I successfully did it based on XYBarCharDemo7 example.
This was pretty easy to adapt to display the "planned interval" and "realization interval". result
To represent the due date I used the "range crosshair" of my xyPlot as follow :

Code: Select all

XYPlot xyPlot = (XYPlot)myChart.getPlot();
xyPlot.setRangeAxis(dateAxis);
xyPlot.setRangeCrosshairVisible(true);
xyPlot.setRangeCrosshairLockedOnData(false);
Minute dueDate = new Minute(task.getDueDate());
xyPlot.setRangeCrosshairValue(dueDate.getLastMillisecond());
But I would like do display the due date value above (or at least around) the crosshair.
I saw a org.jfree.chart.plot.Crosshair object in the javadoc that offers some label related method but I don't know where to get the instance of my crosshair.
I expected something like "myXyPlot.getRangeCrosshair()" but I can't find anything that looks like this.

Some other info you may need to help me :
I create the charts in a web server in order to display them in web pages (Tapestry 5 application).
I use a
NumberAxis as domain
DateAxis as range
XYPlot as plot
XYBarRenderer as renderer
XYIntervalSeriesCollection as dataset
XYIntervalSeries as series (totaly 3 series)

As I am new, there may be a better way to handle all this so I am, of course, open to any suggestion. :D

Thanks a lot for any input. :D

gengar
Posts: 26
Joined: Thu Mar 18, 2010 12:28 am
antibot: No, of course not.

Re: Label on crosshair : how to

Post by gengar » Tue Apr 13, 2010 1:07 am

I don't know whether you can have labels on crosshair, but I have a workaround for this.

You could add a ChartProgressListener to your chart. In the method "chartProgress(ChartProgressEvent event)", set up code to add/remove annotations to/from the chart. Your chart would fire a ChartProgressEvent when the crosshair is moved.

http://www.jfree.org/jfreechart/api/jav ... tener.html

Ghurdyl
Posts: 6
Joined: Fri Apr 09, 2010 1:49 pm
antibot: No, of course not.

Re: Label on crosshair : how to

Post by Ghurdyl » Wed Apr 14, 2010 12:46 pm

thanks for the hint :)

Locked