Hi there, just installed jFreeChart and generated some basic charts and it is really cool... a big thankyou to the people who made it!
Just have a quick question, i am wanting to make a very simple horizontal chart. I would like each bar having a different colour, and labeled on the side, but when i have looked at the samples, it seems to only print out the categories beside the bar and not the series. How would I go about having the series label next to the bar? or do i have to make 8 categories and put one item in each one?
Cheers
John
Categories and Series Explanation
Re: Categories and Series Explanation
Hi John,
You could use eight categories and one series, but then all the bars would be the same color. The reason for this is that the chart legend (if visible) shows the color and name of each series in the dataset.
Or you could use one category and eight series (which I think is what you have tried) in which case the bars will all be different colors but then the axis will just display a single category label.
I'm not sure of a good way to change this without breaking the way the legend works. But if you want to, you could modify the drawCategoryItem(...) method in the HorizontalBarRenderer class. This line gets the series color:
Paint seriesPaint = plot.getSeriesPaint(series);
You could change this to a different color for each category in the dataset.
Regards,
DG.
You could use eight categories and one series, but then all the bars would be the same color. The reason for this is that the chart legend (if visible) shows the color and name of each series in the dataset.
Or you could use one category and eight series (which I think is what you have tried) in which case the bars will all be different colors but then the axis will just display a single category label.
I'm not sure of a good way to change this without breaking the way the legend works. But if you want to, you could modify the drawCategoryItem(...) method in the HorizontalBarRenderer class. This line gets the series color:
Paint seriesPaint = plot.getSeriesPaint(series);
You could change this to a different color for each category in the dataset.
Regards,
DG.