Menu

#14 Divide by zero

open
nobody
None
5
2005-05-18
2005-05-18
marcus
No

I get the following error for my graph:
Warning: Division by zero
in /opt/eperf/matay/graphpite/Image/Graph/Axis.php on
line 404

This is the problematic line:
$labelInterval = $this->_axisSpan()/($this-
>_axisValueSpan()/$this->_labelInterval());

The problem occurs because _axisValueSpan() or
_labelInterval() may return 0, therefore creating a "divide
by zero" scenario.

It occurred for me every time all of my DataSet values
are 0. I fixed it with the following change:
<insert before line 404>

if (($this->_axisValueSpan() == 0) || ($this-
>_labelInterval() == 0)) {
$labelInterval = 1;
}
else

I'm guessing it's not the best fix, but it works for my
case.

Discussion


Log in to post a comment.