1

Possible Duplicate:
Multiple OHLC datasets in one image

Hi So I have plotted a candleStick graph using a OHLCDataItem array, and I am also plotting a line graph over the top using the same array, however at the moment the line graph plots the "open" variable of the OHLCDataItem. How do I get it to plot a different variable.
i.e. the constructor is:

OHLCDataItem(java.util.Date date, double open, double high, double low, double close, double volume)

So currently this is my code setting up the graph:

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);

mainPlot.setDataset(1,  generalDataSet);
mainPlot.setRenderer(1, LineRenderer);

This line: mainPlot.setDataset(1, generalDataSet); is setting up the plot for the line graph, but I cant figure out how to graph a different variable than "open". I think it must be straight forward, but I cant grasp it.

Community
  • 1
  • 1
amlwwalker
  • 3,161
  • 4
  • 26
  • 47

1 Answers1

1

you probably want OHLCSeries and OHLCSeriesCollection (which implements XYDataset), instead of an OHLCDataItem array and DefaultOHLCDataset.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
  • [code] List data = getData(stockSymbol); OHLCDataItem[] dataItems = data.toArray(new OHLCDataItem[data.size()]); OHLCSeries dataserieslist = new OHLCSeries(data.addAll(data)); XYDataset generalDataSet = new DefaultOHLCDataset(stockSymbol, dataItems); XYDataset testSet = new OHLCSeriesCollection(); testSet.setGroup(dataserieslist) XYPlot mainPlot = new XYPlot(generalDataSet, domainAxis, rangeAxis, candleStickRenderer); mainPlot.setDataset(1, testSet); mainPlot.setRenderer(1, LineRenderer); [/code] Sorry Im struggling a bit? – amlwwalker Oct 06 '12 at 23:05
  • Please edit your question with new code, where it will be readable. – trashgod Oct 09 '12 at 21:25