How to draw annotation on a dateAxis domain

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
noss00
Posts: 4
Joined: Tue Aug 05, 2008 4:52 pm

How to draw annotation on a dateAxis domain

Post by noss00 » Thu Aug 07, 2008 10:31 am

hello,
I want to put an annotation to certain points of a chart but the problem is that when the domainAxis is a date I couldn't do it.
And is it possible to add annotation to TimeSeriesChart by :
chart.getXYPlot().addAnnotation because it didn't work neither.

Thanks a lot for helping :wink:

cortesino
Posts: 10
Joined: Mon Aug 11, 2008 7:31 pm

Post by cortesino » Wed Aug 13, 2008 12:05 pm

Hello, you need create a new Annotation with x-value equals a time. This obtain with method getFirstMillisecond() of time class (Second, Minute, Day...).

Regards.

noss00
Posts: 4
Joined: Tue Aug 05, 2008 4:52 pm

Post by noss00 » Wed Aug 13, 2008 1:00 pm

yes thanks a lot, I ve finally found a similar example ...
thanks :wink:

Aniket_kedari
Posts: 17
Joined: Tue Jun 24, 2008 3:03 am

Post by Aniket_kedari » Thu Aug 14, 2008 6:01 am

Hello noss00

I am facing a simillar problem. May I know how you solved it.

noss00
Posts: 4
Joined: Tue Aug 05, 2008 4:52 pm

Post by noss00 » Thu Aug 14, 2008 9:11 am

ok, if you have already created your chart, you just have to do this way :

**************************
final XYPlot plot = chart.getXYPlot();
d= new Day(2,8,2008);
x=d.getFirstMillisecond();
String msg="hello";
annotation = new XYTextAnnotation(msg, x, low);
annotation.setFont(new Font("SansSerif", Font.BOLD, 12));
annotation.setPaint(Color.gray);
plot.addAnnotation(annotation);

****************************
where low is the y of my graph
I hope it resolve your problem... :wink:

Aniket_kedari
Posts: 17
Joined: Tue Jun 24, 2008 3:03 am

Hi noss 00

Post by Aniket_kedari » Fri Aug 15, 2008 2:02 am

thanks a lot for quick reply.
But my problem is a bit different. I am creaeting a Gantt chart , so the plot is a categoryPlot and I want to draw ahorizontal line on it.
Complete code is here
http://www.jfree.org/phpBB2/viewtopic.php?t=25408

I am thankful for your help !!!

Locked