I want to know if changing color of a series is possible right when it is created. I have to write a program in which user can select from a list of variables, and those variables will be plotted. I want to assign a specific color to such variables.
The program creates all the requested series and then adds them to the chart. The color is changed by making the list of variables sorted and keeping a track of which item number corresponds to which series so that corresponding color can be added:
Code: Select all
xyseries[i].add(xData[i]), yData[i]);
xyseriescollection.addSeries(xyseries[i]);
JFreeChart chart = ChartFactory.createXYLineChart(null, "", ytitle, xyseriescollection, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false);
XYPlot xyplot = chart.getXYPlot();
XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer)xyplot.getRenderer();
rr.setSeriesPaint(i, green, true);
Any idea how to do that?