Grid Line painting

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Ted Hill

Grid Line painting

Post by Ted Hill » Fri Sep 20, 2002 1:26 pm

Hello,

I want to do an XY plot where the range on the y-axis will go from -5 to +5.

I want to 'highlight' the horizontal grid line for y == 0.

Is this possible?

Thank you,

Ted Hill

Andreas Schroeder

Re: Grid Line painting

Post by Andreas Schroeder » Fri Sep 20, 2002 1:55 pm

Hi Ted,

Yes, it is possible. Use the

setCrosshairVisible(...)

and

setCrosshairValue(...)

methods of the com.jrefinery.chart.ValueAxis

Regards,

Andreas Schroeder

David Gilbert

Re: Grid Line painting

Post by David Gilbert » Fri Sep 20, 2002 2:36 pm

You could try the addDomainMarker(...) method in the XYPlot class. Create a marker at zero with a thick line...

Regards,

DG.

Ted Hill

Re: Grid Line painting

Post by Ted Hill » Fri Sep 20, 2002 3:23 pm

Andreas,

Thanks for the tip on cross hair.

I'm currently using 0.9.2 and there seems to be a bug:

here is my code to set the crosshair corresponding to y == 0

double horizontalCrossHair = 0;
ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();
yAxis.setCrosshairValue(horizontalCrossHair);
yAxis.setCrosshairPaint(Color.red);
yAxis.setCrosshairVisible(true);

No matter what value I give horizontalCrossHair (e.g. 3, 0, -1, etc.) it always draws at y == 1.

Am I overlooking something?

Thanks,

Ted Hill

Ted Hill

Re: Grid Line painting

Post by Ted Hill » Fri Sep 20, 2002 3:29 pm

This works:

XYPlot plot = (XYPlot)chart.getPlot();
plot.addHorizontalLine(new Integer(0), Color.red);

to draw a horizontal line at y== 0

Thanks,

Ted Hill

Ted Hill

Re: Grid Line painting

Post by Ted Hill » Fri Sep 20, 2002 5:17 pm

David,

Thanks, I downloaded 0.9.3 and am now using setRangeMarker(), works just fine.

Thank you for all your great work on this great product!

Ted Hill

Locked