I create standardized charts from user data that contains several series. Each series has fixed meaning and must be of certain colors for consistency (also, this colors are referred to outside the charts, so JFreeChart is not free to choose them as it likes). Sometimes a series would contain no values, but it still needs to be included in the chart for consistency.
Everything is fine as long as charts show the legends. However, if I hide the legend, colors for series can start to vary depending on whether some series contains nulls or not. To see what I mean, run the attached program with "false" or "true" as its command line argument.
The example uses bar chart, but this is also true for other chart types, e.g. an x-y chart.
As a workaround, adding a getLegendItems() call at the top of draw() method in CategoryPlot.java, XYPlot.java etc. seems to "solve" it.