help using XYAnnotation

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Frank

help using XYAnnotation

Post by Frank » Fri Jan 10, 2003 10:17 pm

has anyone implemented XYAnnotations in an xyplot. can I see how to do so?

David Gilbert

Re: help using XYAnnotation

Post by David Gilbert » Fri Jan 10, 2003 10:24 pm

Hi Frank,

It is a very basic feature at present, it just allows you to add arbitrary text at some data coordinate:

XYPlot plot = myChart.getXYPlot();
Font font = new Font("SansSerif", Font.PLAIN, 9);
plot.addAnnotation(new XYTextAnnotation("Hello world!", font, 10.0, 75.0));

So in the example above, the text "Hello world!" will be displayed at x = 10.0 and y = 75.0 (as long as your axis ranges include those values).

I plan to extend this feature to allow adding lines, arrows and other shapes to charts, but there are lots of other things to get done first.

Regards,

Dave Gilbert

Frank

Re: help using XYAnnotation

Post by Frank » Fri Jan 10, 2003 10:31 pm

C:\j2sdk1.4.1_01\bin>javac DSPGraph.java

DSPGraph.java:13: cannot resolve symbol
symbol : class annotations
location: package chart
import com.jrefinery.chart.annotations;
^
DSPGraph.java:229: cannot resolve symbol
symbol : class XYTextAnnotation
location: class DSPGraph
plot.addAnnotation(new XYTextAnnotation("Hello world!", 10.0, 10
.0));
^
2 errors

C:\j2sdk1.4.1_01\bin>

Frank

Re: help using XYAnnotation

Post by Frank » Fri Jan 10, 2003 10:33 pm

If I
import com.jrefinery.chart.*;

then I still get this:

C:\j2sdk1.4.1_01\bin>javac DSPGraph.java
DSPGraph.java:229: cannot resolve symbol
symbol : class XYTextAnnotation
location: class DSPGraph
plot.addAnnotation(new XYTextAnnotation("Hello world!", 10.0, 10
.0));
^
1 error

C:\j2sdk1.4.1_01\bin>

code looks like this, what you said:

XYPlot plot = chart.getXYPlot();
plot.addAnnotation(new XYTextAnnotation("Hello world!", 10.0, 10.0));

Greg Rokita

Re: help using XYAnnotation

Post by Greg Rokita » Sat Jan 11, 2003 2:50 am

This feature would be really usefull. Identifing certain points on the graph.
Any idea of when it will be available?

David Gilbert

Re: help using XYAnnotation

Post by David Gilbert » Mon Jan 13, 2003 5:09 pm

Hi Greg,

The arrows and lines feature falls into the 'easy but not so critical' category. These tasks tend to drop down my priority list, but then one day (often a Friday) I just decide out of the blue that I want to work on something easy and, voila, it's in the next release. But when I work this way, it is hard to predict the schedule.

Regards,

Dave Gilbert

Antonio Lopes

Re: help using XYAnnotation

Post by Antonio Lopes » Thu Feb 20, 2003 10:12 pm

Hi David,

I use a TimeSeriesChart graphic to display events occurring within a time frame.
I show a horizontal line (with the method addRangeMarker from XYPlot class) to indicate a average value.
I would like to put a "Annotation" over this average value line.
Do you have any idea of when you're going to have it avaliable?

Thanks,

Antonio Lopes

Locked