When I use XYPlot and XYLineAndShapeRenderer with the latest JFreeChart, removing legend reverses the order of the automatically colored lines.
Why? Can this be fixed somehow?
Why does chart.removeLegend(); change the colors of a chart?
-
- Posts: 25
- Joined: Wed Jun 09, 2004 6:15 am
- Location: Helsinki, Finland
- Contact:
Why does chart.removeLegend(); change the colors of a chart?
~ Arkkimaagi ~
Experto Credite
Experto Credite
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
This is a recently reported bug - no fix is available yet.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 2
- Joined: Wed Feb 20, 2013 7:32 pm
- antibot: No, of course not.
Re: Why does chart.removeLegend(); change the colors of a ch
Sorry to be a necromancer here, but I'm still seeing this in version 1.0.14 of JFreeChart. Is there a way around this?
My use case is I have one big chart that has the legend, and then a bunch of little charts that show the same series, but from different perspectives. So I'd like the series in the little charts to have the same colors as in the big chart, but not show the legend on every smaller chart. Keeping the legend on the little charts works fine, but is really ugly. Removing the legends causes the colors to be wrong (apparently reversed).
My use case is I have one big chart that has the legend, and then a bunch of little charts that show the same series, but from different perspectives. So I'd like the series in the little charts to have the same colors as in the big chart, but not show the legend on every smaller chart. Keeping the legend on the little charts works fine, but is really ugly. Removing the legends causes the colors to be wrong (apparently reversed).
Re: Why does chart.removeLegend(); change the colors of a ch
I too am seeing this exact same issue in version 1.0.14. Instead of running chart.removeLegend(), I am using chart.getLegend().setVisible(false);
I have seen in in two scenarios:
1. Just like KevinWorkman, I have one main XYPlot with several other plots showing the same data with different perspectives. The main plot has a certain order and the other plots have the order reversed.
2. I have a scatter plot that you can choose which set of data to view. When switching, the XYDataset gets all of it's XYSeries cleared and new data is added. When switching through the data, the colors chosen are random when the legend is hidden. When the legend is in view, the colors are the same every time.
I have seen in in two scenarios:
1. Just like KevinWorkman, I have one main XYPlot with several other plots showing the same data with different perspectives. The main plot has a certain order and the other plots have the order reversed.
2. I have a scatter plot that you can choose which set of data to view. When switching, the XYDataset gets all of it's XYSeries cleared and new data is added. When switching through the data, the colors chosen are random when the legend is hidden. When the legend is in view, the colors are the same every time.
Re: Why does chart.removeLegend(); change the colors of a ch
Hi, I happened to accidentally find out a counter measure that works fine.
Try this line after "removeLegend();" or "chart.getLegend().setVisible(false);"; it will get your colours back to the previous order palette.
JFreeChart chart;
[code here...]
chart.getXYPlot().setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
Regards,
Adam
Try this line after "removeLegend();" or "chart.getLegend().setVisible(false);"; it will get your colours back to the previous order palette.
JFreeChart chart;
[code here...]
chart.getXYPlot().setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
Regards,
Adam