开发者

Multiple OHLC datasets in one image

开发者 https://www.devze.com 2023-01-06 21:44 出处:网络
How can I chart multiple datasets in one image using JFreeChart ? Essentially I want to chart a stock\'s price and it\'s moving average line in one image.

How can I chart multiple datasets in one image using JFreeChart ?

Essentially I want to chart a stock's price and it's moving average line in one image.

I've tried getting the XYPlot and adding the second dataset, but it does not work.

DefaultOHLCDataset dataset = new DefaultOHLCDataset(symbol, items);
DefaultOHLCDataset dataset2 = new DefaultOHLCDataset(symbol, evs);
JFreeChart chart2 = ChartFactory.createHighLowChart(
    symbol, "minutes", "prices", dataset, true);        
chart2.getXYPlot().setDataset(1, dataset2);

Or is there an开发者_运维技巧y specialized java library for stock trading application that's easier to use?


Note that DefaultOHLCDataset is "A simple implementation of the OHLCDataset interface. This implementation supports only one series." You probably want OHLCSeriesCollection, which also implements OHLCDataset and can hold more than one OHLCSeries.

0

精彩评论

暂无评论...
验证码 换一张
取 消