Fill colours in between trend lines

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jyothy
Posts: 17
Joined: Fri Mar 24, 2006 6:46 am

Fill colours in between trend lines

Post by Jyothy » Tue Jun 20, 2006 11:30 am

I have drawn 3 trend lines in my graph to specify the threshold values in the time series chart with 3 diffrent colours.

Now i would like to fill colours between these trend lines.
Can any one help me??

Here is the code to draw trend lines.
Date date = DateUtilities.createDate(2002,MonthConstants.JANUARY,1);
Date date1 = DateUtilities.createDate(2002,MonthConstants.NOVEMBER,31);

double x1 = (double)date.getTime();
double x2 = (double)date1.getTime();
double y1 = 95.35;
double y2 = 96.48;
double y3 = 97.50

XYLineAnnotation trendline = new XYLineAnnotation(x1,y1,x2,y1,DOTTED_LINE, Color.green);
XYLineAnnotation trendline1 = new XYLineAnnotation(x1,y2,x2,y2,DOTTED_LINE, Color.orange);
XYLineAnnotation trendline2 = new XYLineAnnotation(x1,y3,x2,y3,DOTTED_LINE, Color.red);

plot.addAnnotation(trendline);
plot.addAnnotation(trendline1);
plot.addAnnotation(trendline2);
plot.setRenderer(renderer1);

Thanks in advance,

Jyothy Anjuri

Jyothy
Posts: 17
Joined: Fri Mar 24, 2006 6:46 am

Post by Jyothy » Tue Jun 20, 2006 1:32 pm

I have used XYBoxAnnotation to get the band of colors , but the band is rendered on top of line graph so line graph is not being seen.

I want the band of colors underneath so that on these band of colors the time series graph shd be shown.


Please help!


Jyothy Anjuri

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Tue Jun 20, 2006 1:51 pm

Have you tried using an IntervalMarker instead? As well as marking a range/domain interval correctly, you can also specify whether the marker is rendered under / on top of the data.

Jyothy
Posts: 17
Joined: Fri Mar 24, 2006 6:46 am

Post by Jyothy » Tue Jun 20, 2006 2:33 pm

IntervalMarker takes 2 doubles values x1 to y1, but i need to draw a band from x1 to y1 and x2 to y2.( it would be as a rectangle).

and also this band underneath a graph.



Thanks in advance
Jyothy Anjuri

Jyothy
Posts: 17
Joined: Fri Mar 24, 2006 6:46 am

Post by Jyothy » Wed Jun 21, 2006 9:49 am

i have used tried MarkerBand class but not sucedded.

MarkerAxisBand mab = new MarkerAxisBand(rangeAxis1, x1, y1, x2, y2, new Font("Verdana", Font.PLAIN, 10));
IntervalMarker marker = new IntervalMarker(x1, y1);
marker.setPaint(Color.pink);
mab.addMarker(marker);
rangeAxis1.setMarkerBand(mab);

where
Date date = DateUtilities.createDate(2002,MonthConstants.JANUARY,1);
Date date1 = DateUtilities.createDate(2002,MonthConstants.NOVEMBER,31);

double x1 = (double)date.getTime();
double x2 = (double)date1.getTime();
double y1 = 95.35;
double y2 = 96.48;
double y3 = 97.50;


pls advice what is wrong in the code

Jyothy Anjuri

willi.firulais
Posts: 15
Joined: Fri Jul 28, 2006 4:31 pm

How Annotation can be rendered in the back of line graph

Post by willi.firulais » Wed Feb 14, 2007 7:55 pm

Hallo,
Jyothy wrote:I have used XYBoxAnnotation to get the band of colors , but the band is rendered on top of line graph so line graph is not being seen.
Did you ever succeed with this? The box annotation is a nice feature, but I need them in the background of the series.

Thx, Willi

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Re: How Annotation can be rendered in the back of line graph

Post by RichardWest » Wed Feb 14, 2007 8:30 pm

willi.firulais wrote:The box annotation is a nice feature, but I need them in the background of the series.
Have you tried using:

Code: Select all

public void addAnnotation(XYAnnotation annotation, Layer layer)
with the layer set as "Layer.BACKGROUND"? The full description of this function is on http://www.jfree.org/jfreechart/api/gjd ... derer.html. The XYBoxAnnotation is an extension of XYAnnotation, so as long as you are using a renderer that extends from AbstractXYItemRenderer (which I suspect), you should be able to add the annotation to the background.

Hope this helps,
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Fri Apr 13, 2007 4:56 pm

you can also give transparent color to boxAnnotation.

Locked