I'm using version 0.9.4, trying to draw a horizontal line on my plots at zero. I tried:
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setCrosshairValue(0.0);
rangeAxis.setCrosshairVisible(true);
This always results in a horizontal dotted line on my plot. However, while the line is at y =0 on a few plots, most plots show a line at some other y location.
I have also tried removing the second line of code. Behavior is unchanged.
Can anyone help? Is this fixed in 0.9.5?
Thank you, Ken
NumberAxis.setCrosshair bug in 0.9.4
Re: NumberAxis.setCrosshair bug in 0.9.4
The crosshairs are designed to move around in reponse to mouse clicks. If you just want a fixed line at zero, you should try adding a Marker using the setRangeMarker(...) method.
Regards,
Dave Gilbert
Regards,
Dave Gilbert
Re: NumberAxis.setCrosshair bug in 0.9.4
Yes, I was looking for a fixed line at zero. The line of code to add the marker is just:
plot.addRangeMarker(new Marker(0.0));
Thank you for your help.
plot.addRangeMarker(new Marker(0.0));
Thank you for your help.
Re: NumberAxis.setCrosshair bug in 0.9.4
Hi Dave,
My version: 0.9.4.0.
Im getting a dotted line with addRangeMarker() instead of a solid.
----------------------------------------
JFreeChart chart = ChartFactory.createLineChart(title, labelX, labelY, dataset, bShowLegend);
CategoryPlot catPlot = chart.getCategoryPlot();
BasicStroke stroke = new BasicStroke(2.0f); // marker line with
catPlot.addRangeMarker(new Marker(0.0, Color.BLUE, stroke, Color.RED, 0.0f)); // add marker
catPlot.addRangeMarker(new Marker(1.5)); // another marker, shows also only a dotted line.
----------------------------------------
It works, if I use a TimeSeriesChart and chart.getXYPlot().addRangeMarker(new Marker(0.0, Color.BLACK));
Anything wrong with my code or a JFreechart problem?
My version: 0.9.4.0.
Im getting a dotted line with addRangeMarker() instead of a solid.
----------------------------------------
JFreeChart chart = ChartFactory.createLineChart(title, labelX, labelY, dataset, bShowLegend);
CategoryPlot catPlot = chart.getCategoryPlot();
BasicStroke stroke = new BasicStroke(2.0f); // marker line with
catPlot.addRangeMarker(new Marker(0.0, Color.BLUE, stroke, Color.RED, 0.0f)); // add marker
catPlot.addRangeMarker(new Marker(1.5)); // another marker, shows also only a dotted line.
----------------------------------------
It works, if I use a TimeSeriesChart and chart.getXYPlot().addRangeMarker(new Marker(0.0, Color.BLACK));
Anything wrong with my code or a JFreechart problem?