How to set color for specified chart item?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jiangshachina
Posts: 32
Joined: Fri May 26, 2006 12:56 pm
Location: Beijing, China

How to set color for specified chart item?

Post by jiangshachina » Mon Nov 23, 2009 9:09 am

For instance, I have a bar chart, which has two categories(C1, C2) and three series(S1, S2, S3).
Now I want to set red color for the bar item at (C2, S3), how to do?
Or, I have to customize bar renderer?
Thanks in advance!
a cup of Java, cheers!
Sha Jiang

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: How to set color for specified chart item?

Post by remiohead » Mon Nov 23, 2009 2:24 pm

Correct: you need to extend the BarRenderer class and override the getItemPaint(int, int) method:

Code: Select all

public Paint getItemPaint(final int row, final int column) {
   return clr;
}

jiangshachina
Posts: 32
Joined: Fri May 26, 2006 12:56 pm
Location: Beijing, China

Re: How to set color for specified chart item?

Post by jiangshachina » Tue Nov 24, 2009 1:47 am

Thanks, I'll have a try.
a cup of Java, cheers!
Sha Jiang

Locked