Reputation: 3507
I am trying to make a chart of ohlc bars invisible so that I can leave the window with only the moving average. Here is the code with the two series (ohlc bars and moving average) :
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;
}
For some reason setSeriesVisible function is not working. Any ideas? Thank you.
Upvotes: 2
Views: 1693
Reputation: 205875
HighLowRenderer
ignores getSeriesVisible()
and getBaseSeriesVisible()
, although it does check getDrawOpenTicks()
and getDrawCloseTicks()
. You can replace the OHLCDataset
:
plot.setDataset(0, null);
Alternatively, don't add the OHLCDataset
in the first place; just use it to create the MovingAverage
.
Upvotes: 2