I am creating an XYPlot
with initially null
dataset, and then add multiple (e.g. 2) XYSeriesCollection
instances to it. Like
val chart = ChartFactory.createXYLineChart(...)
val plot = chart.getXYPlot
plot.setDataset(0, dataset0)
plot.setDataset(1, dataset1)
Now I want them to have them in different colors and strokes:
import BasicStroke._
val renderer = plot.getRenderer
renderer.setSeriesPaint(0, Color.black)
renderer.setSeriesPaint(1, Color.red)
renderer.setSeriesStroke(0, new BasicStroke(2.0f))
renderer.setSeriesStroke(1,
new BasicStroke(2.0f, CAP_ROUND, JOIN_ROUND, 1.0f, Array(6f, 6f), 0f))
)
But both appear in black and non-dashed. So I must be making a mistake in terms of understanding the correspondence between datasets and series?
I also tried with plot.getRendererForDataset(dataset)
, but again, both datasets are controlled by the settings for series 0, while the renderer settings for series 1 seem to be irrelevant.