NumberAxis.setCrosshair bug in 0.9.4

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Ken O'Neill

NumberAxis.setCrosshair bug in 0.9.4

Post by Ken O'Neill » Fri Feb 14, 2003 11:53 pm

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

David Gilbert

Re: NumberAxis.setCrosshair bug in 0.9.4

Post by David Gilbert » Mon Feb 17, 2003 9:55 am

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

Ken O'Neill

Re: NumberAxis.setCrosshair bug in 0.9.4

Post by Ken O'Neill » Mon Feb 17, 2003 7:35 pm

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.

Peter

Re: NumberAxis.setCrosshair bug in 0.9.4

Post by Peter » Mon Feb 24, 2003 3:40 pm

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?

Locked