Hello,
In the User's Guide 13.2.5 it says that when you add an additional dataset,
"...if you don’t specify an additional renderer, the primary renderer will be used instead. In that case, the series colors will be shared between the primary dataset and the additional dataset."
Doesn't seem to work for me: I get red on both series.
Using jcommon-1.0.10.jar and jfreechart-1.0.6.jar, jre 1.6.0_05
Code fragments:
// First dataset
TimeSeriesCollection tsc = new TimeSeriesCollection();
tsc.addSeries(priceIndexSeries);
plot.setDataset(0, tsc);
// Axis 0 is automatically provided but fix its label
plot.getRangeAxis(0).setLabel("Cluster Price Index");
// Second dataset
tsc = new TimeSeriesCollection();
tsc.addSeries(coherenceSeries);
plot.setDataset(1, tsc);
// Create and assign an axis to it explicitly.
NumberAxis axis1 = new NumberAxis("Cluster Coherence");
plot.setRangeAxis(1, axis1);
plot.mapDatasetToRangeAxis(1, 1);
Any idea what I'm missing?
Thanks
Jim
Colors for multiple series in TimeSeriesCollection
I'm not sure whether I understand you well...but I recently get through some coloring issues... you may check this thread, may be it helps
http://www.jfree.org/phpBB2/viewtopic.p ... ght=#70429
http://www.jfree.org/phpBB2/viewtopic.p ... ght=#70429
Anyone have a good solution to this problem?
I'm making simple TimeSeriesCollections with one or more datasets each and assigning each of those to their own Range Axis on a TimeSeriesChart. Doing that causes the colors to start over for each TimeSeriesCollection, which is against what the developers guide says.
My main issue is I don't know how many series there will be until creating the chart so I can not manually color them. I've tried manually forcing the same renderer on each DataSet with the same results. I need a way to have an arbitrary number of colors (one per series) for an arbitrary number of ranges axis.
Any help is appreciated,
Dan
EDIT: As a further note, the current MultipleAxisDemo2 and 3 show all red lines. Is this issue a bug in the current version?
I'm making simple TimeSeriesCollections with one or more datasets each and assigning each of those to their own Range Axis on a TimeSeriesChart. Doing that causes the colors to start over for each TimeSeriesCollection, which is against what the developers guide says.
My main issue is I don't know how many series there will be until creating the chart so I can not manually color them. I've tried manually forcing the same renderer on each DataSet with the same results. I need a way to have an arbitrary number of colors (one per series) for an arbitrary number of ranges axis.
Any help is appreciated,
Dan
EDIT: As a further note, the current MultipleAxisDemo2 and 3 show all red lines. Is this issue a bug in the current version?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I think the explanation in the developer guide isn't clear enough. If you have multiple datasets but just one renderer, the series colours assigned to the renderer will be *repeated* for each dataset (e.g. if the renderer is using Color.RED for series 1, it will apply that to series 1 in dataset 1 *and* to series 1 in dataset 2).
The solution is to add a separate renderer for each dataset...then the additional renderer will obtain its own set of colours (and the DrawingSupplier for the plot should ensure that these are unique, if you rely on the auto populate mechanism).
I think it is possible that this may have worked differently in some prior version, but I'd have to go back and check that.
Thanks for spotting the bug in MultipleAxisDemo2 and 3 - I'll fix those (by adding a second renderer in the demo code).
The solution is to add a separate renderer for each dataset...then the additional renderer will obtain its own set of colours (and the DrawingSupplier for the plot should ensure that these are unique, if you rely on the auto populate mechanism).
I think it is possible that this may have worked differently in some prior version, but I'd have to go back and check that.
Thanks for spotting the bug in MultipleAxisDemo2 and 3 - I'll fix those (by adding a second renderer in the demo code).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

