Overlaying HighLow chart with scatter chart
Posted: Tue Apr 14, 2009 6:05 pm
I am trying to mark certain lines of a HighLow chart with a scatter chart. Basically I have identified certain lines that I want highlighted. So on the data consists of zero values and then non-zero values where I want a bar identified. What I am getting is wierd. Instead of the scatter chart symbol printed directy over or under a bar it is printed over and to the side of the bar. Plus it has a faint line coming up from zero. It appears that it is attempting to chart the line even though I have the stroke at 0.0f. So I figure I am missing something. Here is the code:
Here is the result:

What I am really trying to get is:
(I used an image editor to get this)

I am very, very close. Can anybody help get this right?
Code: Select all
DefaultHighLowDataset dataset1 = createStockDataset(stock, stockData, start, end);
TimeSeriesCollection dataset3 = createSignalsDataset(stock, stockData, start, end);
JFreeChart chart = createChart(dataset1, stock);
XYPlot plot = (XYPlot) chart.getPlot();
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
renderer2.setUseOutlinePaint(false);
renderer2.setSeriesPaint(0, Color.green);
renderer2.setSeriesPaint(1, Color.red);
renderer2.setSeriesStroke(0, new BasicStroke(0.0f));
renderer2.setSeriesStroke(1, new BasicStroke(0.0f));
plot.setDataset(2, dataset3);
plot.setRenderer(2, renderer2);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxisForDataset(2);
rangeAxis.setAutoRangeIncludesZero(false);
rangeAxis.setTickMarkInsideLength(1.0f);
rangeAxis.setTickMarkOutsideLength(1.0f);
rangeAxis.setMinorTickCount(1);
rangeAxis.setMinorTickMarksVisible(true);
ChartPanel chartPanel = new ChartPanel(chart, false);
chartPanel.setPreferredSize(new Dimension(1000, 500));
setContentPane(chartPanel);

What I am really trying to get is:
(I used an image editor to get this)

I am very, very close. Can anybody help get this right?