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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top