Bug by HorizontalNumberAxis!?

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

Bug by HorizontalNumberAxis!?

Post by dong » Fri Jun 29, 2001 10:40 am

Hi!
I have a following problem:
I want to create a HorizontalBarPlot and it has
a VerticalCategoryAxis and a HorizontalNumberAxis.
I have only one category with some numbers,
for example: the lowest value is 0.15 and the
highest value is 37.03. So I think, the first gridline
(which has the value 0.0) should be drawed exactly
on the verticalaxis.
But the first gridline of the barChart what I gotten
is 7 pixel shifted to RIGHT.


I found the function "autoAdjustRange()" in the class
HorizontalNumberAxis:

....
double upper = hvp.getMaximumHorizontalDataValue().doubleValue();
double lower = hvp.getMinimumHorizontalDataValue().doubleValue();
double range = upper-lower;
....
if (this.autoRangeIncludesZero()) {
if (upper!=0.0) upper = Math.max(0.0, upper+0.05*range);
if (lower!=0.0) lower = Math.min(0.0, lower-0.05*range);
}
....

if lower=0.15 and upper=37.03, so the range=36.88.
Now if lower-0.05*range, I got a negativ value "-1.694".
This is the reason of the right-shifting.

I added follow code after to fix this problem:
if (lower < 0.0)
{
lower = 0.0;
}

It works.
I dont know what happens if we have really negativ
number values.

David Gilbert

RE: Bug by HorizontalNumberAxis!?

Post by David Gilbert » Sun Jul 15, 2001 7:26 pm

Hi Dong,

Thanks for the bug report...I'll have a think about how I think it should work for negative numbers also, then I'll fix the problem...

Regards,

DG.

Locked