I have a dataset which contains the price data for two stocks over a period of time. When plotting the dataset, both line graphs are of the same color.
Code: Select all
JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "", "", priceDataset, true, true, false);
chart.setBackgroundPaint(new Color(255, 255, 240));
XYPlot plot = chart.getXYPlot();
NumberAxis rangeAxis1 = (NumberAxis) plot.getRangeAxis();
rangeAxis1.setLowerMargin(0.5);
rangeAxis1.setUpperMargin(0.4);
DecimalFormat format = new DecimalFormat("0");
rangeAxis1.setNumberFormatOverride(format);
XYItemRenderer renderer1 = plot.getRenderer();
renderer1.setPaint(new Color(0, 102, 221));