为了在同一个图表中表示它们的值,我怎么能在一个图中添加一个OHLCSeriesCollection和一个TimeSeriesCollection?
答案 0 :(得分:9)
OHLCSeriesCollection和TimeSeriesCollection都基于XYDataset,因此您应该能够将它们添加到XYPlot中,如下所示:
JFreeChart chart = // create your XY chart here.
XYPlot plot = chart.getXYPlot();
OHLCSeriesCollection ohlsSeriesDataset = // create you ohlc dataset here.
TimeSeriesCollection timeSeriesDataset = // create you time dataset here.
AbstractXYItemRenderer olhsSeriesRenderer = // create your ohlc renderer here.
AbstractXYItemRenderer timeSeriesRenderer = // create your time renderer here.
plot.setDataset(0, ohlsSeriesDataset);
plot.setDataset(1, timeSeriesDataset);
plot.setRenderer(0, olhsSeriesRenderer);
plot.setRenderer(1, timeSeriesRenderer);
用于olhsSeriesRenderer和timeSeriesRenderer的渲染器类型实际上取决于您要生成的图表类型,所以我不能在这里给出具体细节。
我自己没有尝试使用XY数据集,但我已经能够使用它来组合CategoryDatasets。