Thicker horizonal line at vertical position 0

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

Thicker horizonal line at vertical position 0

Post by Tom Furrer » Tue Dec 04, 2001 10:25 am

Is there a way to get the horizontal line at vertical position 0 to be drawn thicker than the other horizontal lines.

Or alternatively have the negative part of the y-axis be drawn in another color (i.e. red)?

Rgds,
Tom

David Gilbert

RE: Thicker horizonal line at vertical position 0

Post by David Gilbert » Thu Dec 06, 2001 10:20 am

Hi Tom,

You would need to modify the draw method in the Plot class (actually, whatever subclass of Plot you need this in). I'll have a think about defining another attribute for defining the Stroke to use for drawing the zero lines...

Regards,

DG.

Tom Furrer

RE: Thicker horizonal line at vertical position 0

Post by Tom Furrer » Thu Dec 06, 2001 1:37 pm

I've implemented your suggestion. I actually added some code to the draw method of the VerticalNumberAxes for drawing the gridline at the 0-tick differently.

It would be a cool addition to have a setGridStrokeZero() and setGridPaintZero() methods that are taken into account when drawing the gridlines.

BTW: Another user suggested to use the addHorizontalLine() and addVerticalLine() methods of the XYPlot. This works, but (a) those line start and end points are not where I assumed they should be and (b) the horizontal line was a pixel or so above the grid line at tick 0. I had to change the drawHorizontalLines() method in XYPlot from

g2.drawLine(0,
(int)getVerticalValueAxis().translatedValue((Number)horizontalLines.get(i), plotArea),
(int)(plotArea.getWidth()),
(int)getVerticalValueAxis().translatedValue((Number)horizontalLines.get(i), plotArea));

to

Line2D line = new Line2D.Double(plotArea.getX(),
getVerticalValueAxis().translatedValue((Number)horizontalLines.get(i), plotArea),
plotArea.getMaxX(),
getVerticalValueAxis().translatedValue((Number)horizontalLines.get(i), plotArea));
g2.draw(line);

which is eqivalent to the code for drawing the grid lines. was that some error in the code or did I misunderstand something?

Regards,
Tom

Locked