Subject: | Fwd: SVG-Sparkline-0.36 |
Date: | Thu, 24 Oct 2013 20:41:13 +1000 |
To: | "bug-SVG-Sparkline [...] rt.cpan.org" <bug-SVG-Sparkline [...] rt.cpan.org> |
From: | Peter Robinson <pjrlist [...] gmail.com> |
Hello,
I have found the Sparkline module crashes when all values passed are equal to zero. In my case it is valid data and I have put in a work-around to skip generating the Sparkline if everything is zero. I already had statistics-descriptive giving me min, max, avg, etc and just skip the chart if min and max are both zero. It would be useful to have the module exit cleanly somehow, rather than attempting to divide by zero.
Details of the error are below:
Regards, Peter Robinson
In Brisbane, Australia
Distribution: SVG-Sparkline-0.36
Perl version:
This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x86-multi-thread
Binary build 1603 [296746] provided by ActiveState http://www.ActiveState.com
Built Mar 13 2013 11:29:21
OS Version
Windows 7 Professional
Service Pack 1
64 Bit v1.08.00.AF
Code used to force the error:
use strict;
use warnings;
use diagnostics;
use SVG::Sparkline;
my @data = ( 0, 0, 0, 0, 0, 0, 0, 0 ) ;
my $sl = SVG::Sparkline->new( Line => { values => \@data } );
Error messages:
Show quoted text
>perl CrashSparkline.pl
Illegal division by zero at C:/Perl/site/lib/SVG/Sparkline/Utils.pm line 43 (#1)
(F) You tried to divide a number by 0. Either something was wrong in
your logic, or you need to put a conditional in to guard against
meaningless input.
Uncaught exception from user code:
Illegal division by zero at C:/Perl/site/lib/SVG/Sparkline/Utils.pm line 43.
SVG::Sparkline::Utils::calculate_yscale_and_offset(SVG::Sparkline=HASH(0x5002d4), 0, 0) called at C:/Perl/site/lib/SVG/Sparkline/Line.pm line 28
SVG::Sparkline::Line::make("SVG::Sparkline::Line", SVG::Sparkline=HASH(0x5002d4)) called at C:/Perl/site/lib/SVG/Sparkline.pm line 79
SVG::Sparkline::_make(SVG::Sparkline=HASH(0x5002d4), "Line") called at C:/Perl/site/lib/SVG/Sparkline.pm line 52
SVG::Sparkline::new("SVG::Sparkline", "Line", HASH(0x4ffd24)) called at CrashSparkline.pl line 6