stretchr
stretchr

Reputation: 615

Key colours JFreeCharts

I'm generating stackedbarcharts and piecharts using jfreecharts. Both types of charts use the same labels. For example I have John, Mike, Sandra, Pushpalika in both. Is there a way I can ensure that the colour used to represent each person is the same across both types of charts?

Upvotes: 0

Views: 54

Answers (1)

David Gilbert
David Gilbert

Reputation: 4477

In general if the series keys in your CategoryDataset (for the bar chart) are in the same order as the keys in your PieDataset (for the pie chart), the auto-selected colors will be the same on both charts. However, if you really want to be sure then you should set the colors manually, using PiePlot's setSectionPaint() method and the stacked bar renderer's setSeriesPaint() method.

Upvotes: 2

Related Questions