Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top