jfreechart plotting line chart on candlestick chart
Hi everyone, new to this forum.
Im learning about plotting graphs in Java, and have had success plotting a candlestick graph in jfreecharts. I have now plotted a line graph on top of that. The problem is my line graph is currently plotting from the same dataSet as my candlestick chart and is plotting the closing points. I want to be able to decide which points of the OHLCDataItem to plot. I.e I may want to plot the "open" variable as a line chart or whatever. Also, OHLCDataItem OHLCDataItem want four data points, whereas for my line graph, I just want the date, and another variable of my choice.
These are the lines that are relevant:
so the data comes into data, each item containing a date followed by five doubles.
List<OHLCDataItem> data = getData(stockSymbol);
OHLCDataItem dataItems = data.toArray(new OHLCDataItem[data.size()]);
XYDataset generalDataSet = new DefaultOHLCDataset(stockSymbol, dataItems);
XYPlot mainPlot = new XYPlot(generalDataSet, domainAxis, rangeAxis, candleStickRenderer);
generalDataSet turns that into data that the candlestick graph plots. mainPlot plots that data on the graph, then the next two lines change the renderer to the line graph plotter, but still using the same data set, and this is where Im no sure how to select which of the five doubles to plot against the date.
Any one done this?
Any examples would be greatly appreciated.