我正在尝试使 ohlc 柱形图不可见,以便我可以仅保留移动平均线的窗口。
这是两个系列(ohlc 柱和移动平均线)的代码:
private static JFreeChart createChart(OHLCDataset dataset)
{
JFreeChart chart = ChartFactory.createHighLowChart(
"HighLowChartDemo2",
"Time",
"Value",
dataset,
true);
XYPlot plot = (XYPlot)chart.getPlot();
DateAxis axis = (DateAxis)plot.getDomainAxis();
axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
NumberAxis yAxis = (NumberAxis)plot.getRangeAxis();
yAxis.setNumberFormatOverride(new DecimalFormat("$0.00"));
//overlay the moving average dataset...
XYDataset dataset2 = MovingAverage.createMovingAverage(dataset, "-MAVG", 3 * 24 * 60 * 60 * 1000L, 0L);
plot.setDataset(1, dataset2);
plot.setRenderer(1, new StandardXYItemRenderer());
XYItemRenderer theRenderer = plot.getRenderer(0);
theRenderer.setSeriesVisible(0, false);
return chart;
}
由于某种原因 setSeriesVisible 函数不起作用。
有任何想法吗?
谢谢。
HighLowRenderer
忽略getSeriesVisible()
and getBaseSeriesVisible()
,虽然它does check getDrawOpenTicks()
and getDrawCloseTicks()
。您可以更换OHLCDataset
:
plot.setDataset(0, null);
或者,不要添加OHLCDataset
首先;只需用它来创建MovingAverage
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)