Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have 3 series:

XYSeries s1 = new XYSeries("one");
s1.add(1,0);
s1.add(2,1);

XYSeries s2 = new XYSeries("two");
s1.add(3,0);
s1.add(4,1);

XYSeries s3 = new XYSeries("three");
s1.add(5,0);
s1.add(6,1);

Which i plot as a XYLineChart:

XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
dataset.addSeries(s3);

JFreeChart chart = ChartFactory.createXYLineChart("title", "x", "y", dataset, PlotOrientation.VERTICAL, false, false, false);

and add to a panel:

ChartPanel cp = new ChartPanel(chart);
panel_1.add(cp, BorderLayout.CENTER);
panel_1.validate();

How do i make it so series s1 and s2 are the same colour, and s3 is different?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
252 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use the renderer's setSeriesPaint() method to specify the series and paint. Also consider using a custom DrawingSupplier, mentioned here. More generally, you can override the desired get*Paint() methods to establish any desired color scheme, as shown here for getItemFillPaint()

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...