change part color of pie chart

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

change part color of pie chart

Post by robert » Wed Jun 26, 2002 10:57 am

When I divide the pie chart into only 2 parts, their part colors are automatically red and blue. If I want the colors are red and yellow, then how could I do it?

Thanks a lot!

Ray Mercer

Re: change part color of pie chart

Post by Ray Mercer » Wed Jun 26, 2002 11:26 am

//Warning! - Air code...
PiePlot plot = (PiePlot)chart.getPlot();
ArrayList categories = new ArrayList(plot.getCategories());
Color[] colors = new Color[categories.size()];
...
//set your colors here
colors[0]= Color.red;
colors[1]= Color.yellow;
...
plot.setSeriesPaint(colors);

Hope this helps,
Ray Mercer

robert

Re: change part color of pie chart

Post by robert » Thu Jun 27, 2002 2:44 am

Thank you very much for helping me in time!

Locked