Changing color of Stacked Bar

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ponic
Posts: 28
Joined: Thu Aug 04, 2005 7:32 pm

Changing color of Stacked Bar

Post by ponic » Sun Oct 02, 2005 7:28 am

Hello,

How can I change the color of the stacked bars, at the moment it is red and blue, I would like to change to green and red.

Any help is highly appreciable.

Thanks

poppins
Posts: 10
Joined: Thu Sep 01, 2005 12:17 pm
Location: India

Changing color of Stacked Bar

Post by poppins » Tue Oct 04, 2005 1:24 pm

For every different series in the chart, you see a diiferent colored bar. So, if there are two series then their colors would be Blue and Red by default.

Changing this default setting is simple,

eg, if you are using a CategoryPlot to draw a stacked bar chart, then

Code: Select all


 //get the renderer from CategoryPlot
 CategoryItemRenderer r = plot.getRenderer();
  
 //set a different color for each series
 r.setSeriesPaint(0, Color.Green);
 r.setSeriesPaint(1, Color.Gray);
 //...

Hope this must help,

Nitin

Locked