How to make the color of the line change as it crosses limit

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
statik213
Posts: 6
Joined: Wed May 25, 2005 3:29 am

How to make the color of the line change as it crosses limit

Post by statik213 » Thu May 26, 2005 9:35 pm

Hi,
I'm sure this is simple but I still haven't figured out how things relate to each other yet to do this right. Any help would be greatly appreciated.

I have a TimeSeries and I'd like the curve to change color when it crosses certain limits. Can I specify a 'smart' Stroke that's sensistive to the value it's drawing?
I could have seperate TimeSeries's for each colored bracket and set the color for each of these TimeSeries's and do the comparison's myself and add the values to the right series. Is this the way to do it?

Also, can I add special 'Tick' lines that go across the plot to highlight these limits?

I've bought the developer guide and I couldnt' find any examples like this, it'd be great if anyone can tell me pages/examples I can check out in the developer guide.

Thanks!

skunk

Post by skunk » Fri May 27, 2005 11:31 pm

I use some code like this

Code: Select all

XYItemRenderer renderer = new StandardXYItemRenderer() {
	final Stroke thin = new BasicStroke(0.5f);
	final Stroke thick = new BasicStroke(1.5f);
	public Stroke getItemStroke(int series, int item) {
                ..
                ..
		return (a > b) ? thick : thin;
	}
};

skunk

Post by skunk » Fri May 27, 2005 11:36 pm

To change the color I use this

Code: Select all

XYItemRenderer renderer = new StandardXYItemRenderer() {
   public Paint getItemPaint(int series, int item) {
                ..
                ..
      return (a > b) ? Color.green : Color.red;
   }
};

statik213
Posts: 6
Joined: Wed May 25, 2005 3:29 am

THanks!

Post by statik213 » Sat May 28, 2005 12:45 am

That's great!!!
Knew it was something simple like that.... this is a HUGE library... will take a long time before I get the hang of it.

Thanks a lot, appreciate it.

tony01
Posts: 5
Joined: Tue Aug 02, 2005 12:44 pm

Post by tony01 » Fri Aug 05, 2005 9:30 am

skunk wrote:To change the color I use this

Code: Select all

XYItemRenderer renderer = new StandardXYItemRenderer() {
   public Paint getItemPaint(int series, int item) {
                ..
                ..
      return (a > b) ? Color.green : Color.red;
   }
};
HI,skunk
Could you tell me more how to use this code?
I realllllllllllllllllly have no idea about it..... :oops:

Could you give me some example ?

Thank you

Locked