Multiple OHLC datasets in one image

て烟熏妆下的殇ゞ 提交于 2019-12-30 11:51:32

问题


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 any specialized java library for stock trading application that's easier to use?


回答1:


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.



来源:https://stackoverflow.com/questions/3221844/multiple-ohlc-datasets-in-one-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!