Bar chart color selection

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jean-marie condom

Bar chart color selection

Post by jean-marie condom » Thu Oct 04, 2001 2:03 pm

hello

my question is a little similar to some that have been
posted about the possibility to set colors of bars
(ex : #409711).
in my case I would like that all bars belonging to
the same category have the same color !
It seems that this is not yet implemented in jfreechart.jar.
Is it however possible to get this result by derivating
a particular method where I could control the color
for each bar by knowing the serie and the category
to which this bar belongs !

thanks for any answer

jean-marie

David Gilbert

RE: Bar chart color selection

Post by David Gilbert » Wed Oct 10, 2001 9:10 am

Hi Jean-Marie,

In the VerticalBarPlot class, there is a private method getBars() that returns a list of bars for the plot. The color is set with the following line:

Paint paint = chart.getSeriesPaint(seriesIndex);

I think you could replace seriesIndex with currentCategoryIndex and you would get the effect you want (except maybe the chart legend would then be colored wrong).

Perhaps the best approach would be to create a new method chart.getItemPaint(series, category) and return whatever color you want from that method. In that case, though, I don't know what the legend should show...

Regards,

DG.

jean-marie condom

RE: Bar chart color selection

Post by jean-marie condom » Wed Oct 10, 2001 1:54 pm

thanks David !

I chose the first solution and it works fine !

jean-marie

Locked