Subject: | Division by 0 error |
From: Alexander Hartmaier <Alexander.Hartmaier@DELETED>
Date: Tue, 10 Jun 2003 13:17:17 +0200
To: martien.verbruggen@tradingpost.com.au
Subject: GD::Graph division by 0
Hi Martien!
I've a problem with GD::Graph if all data-points are 0.
This line (1661 in version 1.37 of axestype.pm) in
'/usr/lib/perl5/site_perl/5.8.0/GD/Graph/axestype.pm' triggers a
division by 0:
my $ratio = $scale_1 / $scale_2;
I've changed it to:
my $ratio = ($scale_2 == 0) ? 1 : $scale_1 / $scale_2;
Now the graph looks ok and the division by 0 is gone.
I don't looked further what $ratio is used for so you may want to change
the '1' which is used if $scale_2 is zero to another value.
Would be nice if this patch is included in the next CPAN version of GD::
Graph =)
Yours sincerly
Alexander Hartmaier
T-Systems