Class: org.jfree.chart.ChartFactory
Function: public static JFreeChart createPieChart(String title, PieDataset dataset, PieDataset previousDataset...
Lines: 516-596
Version: 1.0.19
Bug description: this function does not generate a difference PieChart as intended but instead generates a PieChart with the Theme's default colours.
Reasons:
- key stored in plot.sectionPaintMap is key, key stored in dataset variable series is key + series.setValue(key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")"
- currentTheme.apply(chart); wipes chart.sectionPaintMap and is applied after calculating the paints.
Suggested fix:
Restructure the code so if(showDifference) is above if (greenForIncrease) and change the value of the variable key to the key used series.setValue e.g. key = key + "(+100%)" and similar so that plot.sectionPaintMap and series match.
Move currentTheme.apply(chart); above calculating and applying the colours as doing it after wipes them.
Attached:
A visual representation of current stock behaviour and intended result as caused by restructuring.
Guess I messed up the formatting a bit, hope it's still clear.