Arbitrary colours for bar, and plot graphs.

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

Arbitrary colours for bar, and plot graphs.

Post by Mof » Tue Dec 17, 2002 7:43 am

G'day all,

I want to mainly do non-category bar charts, and many data point line plots, but I need the ability to easily set the colour of all the bars to red for example, and then set one particular bar to be blue. I would also like to be able to change the shape of the plot points to all be the same except one or more etc...

Is this easily doable in JFreeChart, and if not would it take long for me to add such a feature?

Thanks,
Mof.

David Gilbert

Re: Arbitrary colours for bar, and plot graphs.

Post by David Gilbert » Wed Dec 18, 2002 10:25 am

Hi Mof,

The easiest way to do that would be to create your own renderer. Take a look at the drawItem(...) method in the VerticalBarRenderer.java source file, you'll see the following code:

Paint itemPaint = null;
if (!getUseCategoriesPaint()) {
itemPaint = getFillPaint(0, row);
}
else {
itemPaint = getCategoryPaint(column);
}
g2.setPaint(itemPaint);
g2.fill(bar);

You could change this code to set the colors to whatever you wanted...

Regards,

Dave Gilbert

Mof

Re: Arbitrary colours for bar, and plot graphs.

Post by Mof » Wed Dec 18, 2002 11:14 pm

Would this mean that I would need to create my own render for each chart type that I wish to use ?

Mof.

Locked