I am using JFreeChart to render a candlestick chart with multiple datasets. Specifically I am trying to have a color variation on the smaDataset thats using a XYLineandShapeRenderer. After adding the sma100 and 200 series to the dataset and applying the renderer to it, I get no effect and the lines are both blue no matter what I do.
CandlestickRenderer renderer = new CandlestickRenderer();
renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
DateAxis xAxis = new DateAxis("Time");
XYPlot pricePlot = new XYPlot(ohlcDataset, xAxis, new NumberAxis("Price"), renderer);
//DEBUG
pricePlot.setDataset(1, createSMADataset(this.series, 100));
pricePlot.setDataset(2, createSMADataset(this.series, 200));
pricePlot.mapDatasetToRangeAxis(1, 0);
pricePlot.mapDatasetToRangeAxis(2, 0);
XYLineAndShapeRenderer smaRenderer = new XYLineAndShapeRenderer(true, false);
smaRenderer.setSeriesPaint(1, Color.BLUE);
smaRenderer.setSeriesPaint(2, Color.RED);
pricePlot.setRenderer(1, smaRenderer);
pricePlot.setRenderer(2, smaRenderer);
pricePlot.setRangeGridlinePaint(Color.WHITE);
pricePlot.setDomainGridlinesVisible(false);
pricePlot.setRangeGridlinesVisible(false);
NumberAxis numberAxis = (NumberAxis) pricePlot.getRangeAxis();
pricePlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
pricePlot.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
numberAxis.setAutoRangeIncludesZero(false);
// combinedPlot
CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(xAxis); // DateAxis
combinedPlot.setGap(10.0);
combinedPlot.setOrientation(PlotOrientation.VERTICAL);
//add plots to combined plot
combinedPlot.add(pricePlot, 80);
combinedPlot.add(getRSIPlot(), 20);