一幅图像中的多个OHLC数据集 [英] Multiple OHLC datasets in one image
问题描述
如何使用JFreeChart在一张图像中绘制多个数据集?
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.
我尝试获取XYPlot并添加第二个数据集,但是它不起作用.
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);
还是有专门用于股票交易的Java库更易于使用?
Or is there any specialized java library for stock trading application that's easier to use?
推荐答案
请注意, DefaultOHLCDataset
是"OHLCDataset
接口的简单实现.此实现仅支持一个系列."您可能需要 OHLCSeriesCollection
,它也实现了OHLCDataset
,并且可以容纳多个 OHLCSeries
.
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
.
这篇关于一幅图像中的多个OHLC数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!