Help

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

Help

Post by Siva » Sun Jan 05, 2003 11:24 pm

I have a verticalbar chart with values. Say, for example, it has values as follows:

double[][] data = new double[][] {
{ 10.0, 40.0, 30.0, 50.0, 60.0, 70.0, 90.0, 80.0 }};
My need is that i have to display the vertical bars with different colors.

Green if value is 100
Yellow if value is >=80
Red if value is <80

I have tried setting the series color , but it changes the whole color. Is there anyway i can do this?

Am creating chart using 'ChartFactory.createVerticalBarChart'

Thanks in advance

Siva

Sachin Kakkar

Re: Help

Post by Sachin Kakkar » Tue Jan 07, 2003 7:45 am

try making three series each with different color also probably you can set the distance between the bars of a series using "setItemGapsPercent" to 0 to minimize the effect of these looking like different series instead of 1

David Gilbert

Re: Help

Post by David Gilbert » Tue Jan 07, 2003 11:15 am

Hi Siva,

If you want to change the color of a bar based on the current value, then you need to create a custom renderer. Take a look at the source code for the VerticalBarRenderer class - you'll see in the drawItem(...) method where the color is set, that's where you need to modify the code.

Regards,

Dave Gilbert

Locked