Text Annotation

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

Text Annotation

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

Hi David,

I use a TimeSeriesChart graphic to display events occurring within a time frame.
I show a horizontal line (with 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

David Gilbert

Re: Text Annotation

Post by David Gilbert » Fri Feb 21, 2003 4:28 pm

Hi Antonio,

If you want to add the text manually, you can create an XYTextAnnotation object at some (x, y) coordinate, and add it to the XYPlot.

Alternatively, you could modify the drawRangeMarker(...) method inherited from the AbstractXYItemRenderer class and get it to draw the value as well as the line.

Regards,

Dave Gilbert

Tim

Re: Text Annotation

Post by Tim » Mon Feb 24, 2003 8:53 pm

Is there an easy way to put a text annotation on a Category Plot?

David Gilbert

Re: Text Annotation

Post by David Gilbert » Wed Feb 26, 2003 1:05 am

There is currently *no* way to put a text annotation on a CategoryPlot. The annotations framework needs extending to cover this.

Regards,

Dave Gilbert

Xingfeng

Re: Text Annotation

Post by Xingfeng » Wed Mar 05, 2003 10:11 pm

Back to the first reply to the TimeSeries Chart, Dave said,

"If you want to add the text manually, you can create an XYTextAnnotation object at some (x, y) coordinate, and add it to the XYPlot."

The Constructor for XYTextAnnotation is:

XYTextAnnotation(java.lang.String text, double x,
double y)

As in most cases we only know the data values, so we need to use:

translateValueToJava2D(double dataValue, java.awt.geom.Rectangle2D dataArea)

available in ValueAxis class, which is used to trnaslate data values to corrdinates.

My question is, how can I construct this dataArea object? Where do I get the bounds of this Rectangle2D ?

Thanks,

Xingfeng

Locked