symmetric axis around zero

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Martin
Posts: 23
Joined: Thu Apr 24, 2003 10:25 am
Location: Germany-Essen

symmetric axis around zero

Post by Martin » Fri Sep 03, 2004 11:06 am

Hi,
I want to display a TimeSeriesChart with two range axis; one on the left and one on the right side of the chart. The two axis should be symmetric around zero so that zero lines of both axis are identical. Therefore I use the following code which works fine:

Code: Select all

/*symmetric axis around 0*/
double am0 = Math.max(Math.abs(myPlot.getRangeAxis(0).getLowerBound()),Math.abs(myPlot.getRangeAxis(0).getUpperBound()));
double am1 = Math.max(Math.abs(myPlot.getRangeAxis(1).getLowerBound()),Math.abs(myPlot.getRangeAxis(1).getUpperBound()));
Range adj0 = new Range(-1*am0,am0);
Range adj1 = new Range(-1*am1,am1);
myPlot.getRangeAxis(0).setRange(adj0);
myPlot.getRangeAxis(1).setRange(adj1);
Furthermore I enabled zooming. Everything is fine when I zoom in. But when I zoom out the two axis are not symmetric anymore, due to some automatic adjustment.
How can I fix it? Any ideas?

Thanks for your help
Martin

Locked