This queue is for tickets about the Chart-Strip CPAN distribution.

Report information
The Basics
Id:
72288
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
davidp [...] preshweb.co.uk
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
1.07
Fixed in:
(no value)



Subject: Div by zero with < 0.5 datapoints
Trying to chart a dataset with values below 0.5, it seems the data points are being rounded down to zero then used in division at line 700. Illegal division by zero at /usr/local/share/perl/5.10.0/Chart/Strip.pm line 700. 699: $st = floor( $tp / $is ) * $is; # -> 4 - 8, ceil -> 2 - 4 700: $low = int( $min / $st ) * $st;
module has been tested with datapoints less than 0.5. cannot reproduce. please include sample code that demonstrates the problem.
Thanks for the fast reply! On 2011-11-09 00:19:31, JAW wrote:
Show quoted text
> module has been tested with datapoints less than 0.5. > cannot reproduce. > > please include sample code that demonstrates the problem.
Ah - in knocking up a test case to produce, I've found it only seems to happen with lots of data points. The test case I used is attached; it generates a graph fine all the way up until it reaches the attempt with 89 data points, then crashes: [...] Testing with 87 data points Testing with 88 data points Testing with 89 data points Illegal division by zero at /usr/local/share/perl/5.10.0/Chart/Strip.pm line 700.
Subject: chart-strip-test-case.pl
#!/usr/bin/perl use strict; use Chart::Strip; my @dataset = ( { "time" => 1320772679, value => "0.4" }, { "time" => 1320772690, value => "0.4" }, { "time" => 1320772701, value => "0.5" }, { "time" => 1320773222, value => "0.5" }, { "time" => 1320773282, value => "0.4" }, { "time" => 1320773341, value => "0.2" }, { "time" => 1320773402, value => "0.5" }, { "time" => 1320773462, value => "0.4" }, { "time" => 1320773522, value => "0.5" }, { "time" => 1320773582, value => "0.5" }, { "time" => 1320773642, value => "0.5" }, { "time" => 1320773702, value => "0.5" }, { "time" => 1320773762, value => "0.3" }, { "time" => 1320773821, value => "0.5" }, { "time" => 1320773882, value => "0.4" }, { "time" => 1320773942, value => "0.5" }, { "time" => 1320774002, value => "0.5" }, { "time" => 1320774062, value => "0.5" }, { "time" => 1320774122, value => "0.5" }, { "time" => 1320774182, value => "0.4" }, { "time" => 1320774243, value => "0.4" }, { "time" => 1320774302, value => "0.4" }, { "time" => 1320774361, value => "0.5" }, { "time" => 1320774422, value => "0.3" }, { "time" => 1320774482, value => "0.4" }, { "time" => 1320774542, value => "0.4" }, { "time" => 1320774602, value => "0.5" }, { "time" => 1320774662, value => "0.4" }, { "time" => 1320774722, value => "0.4" }, { "time" => 1320774781, value => "0.4" }, { "time" => 1320774841, value => "0.4" }, { "time" => 1320774902, value => "0.5" }, { "time" => 1320774962, value => "0.5" }, { "time" => 1320775022, value => "0.5" }, { "time" => 1320775082, value => "0.5" }, { "time" => 1320775142, value => "0.5" }, { "time" => 1320775202, value => "0.3" }, { "time" => 1320775263, value => "0.4" }, { "time" => 1320775322, value => "0.5" }, { "time" => 1320775382, value => "0.4" }, { "time" => 1320775442, value => "0.4" }, { "time" => 1320775503, value => "0.5" }, { "time" => 1320775561, value => "0.4" }, { "time" => 1320775622, value => "0.5" }, { "time" => 1320775682, value => "0.5" }, { "time" => 1320775742, value => "0.5" }, { "time" => 1320775861, value => "0.4" }, { "time" => 1320775922, value => "0.5" }, { "time" => 1320775981, value => "0.4" }, { "time" => 1320776041, value => "0.4" }, { "time" => 1320776102, value => "0.4" }, { "time" => 1320776162, value => "0.4" }, { "time" => 1320776222, value => "0.4" }, { "time" => 1320776282, value => "0.4" }, { "time" => 1320776341, value => "0.3" }, { "time" => 1320776401, value => "0.4" }, { "time" => 1320776461, value => "0.4" }, { "time" => 1320776522, value => "0.5" }, { "time" => 1320776582, value => "0.4" }, { "time" => 1320776642, value => "0.4" }, { "time" => 1320776702, value => "0.4" }, { "time" => 1320776762, value => "0.5" }, { "time" => 1320776822, value => "0.5" }, { "time" => 1320776882, value => "0.4" }, { "time" => 1320776942, value => "0.4" }, { "time" => 1320777003, value => "0.4" }, { "time" => 1320777061, value => "0.3" }, { "time" => 1320777123, value => "0.5" }, { "time" => 1320777181, value => "0.5" }, { "time" => 1320777241, value => "0.4" }, { "time" => 1320777302, value => "0.4" }, { "time" => 1320777362, value => "0.4" }, { "time" => 1320777422, value => "0.4" }, { "time" => 1320777482, value => "0.4" }, { "time" => 1320777542, value => "0.5" }, { "time" => 1320777602, value => "0.5" }, { "time" => 1320777662, value => "0.5" }, { "time" => 1320777722, value => "0.5" }, { "time" => 1320777781, value => "0.4" }, { "time" => 1320777841, value => "0.5" }, { "time" => 1320777902, value => "0.4" }, { "time" => 1320777962, value => "0.4" }, { "time" => 1320778022, value => "0.3" }, { "time" => 1320778082, value => "0.4" }, { "time" => 1320778142, value => "0.5" }, { "time" => 1320778202, value => "0.4" }, { "time" => 1320778261, value => "0.4" }, { "time" => 1320778321, value => "0.5" }, { "time" => 1320778382, value => "0.6" }, { "time" => 1320778442, value => "0.5" }, { "time" => 1320778503, value => "0.5" }, { "time" => 1320778562, value => "0.4" }, { "time" => 1320778623, value => "0.4" }, { "time" => 1320778682, value => "0.4" }, { "time" => 1320778743, value => "0.4" }, { "time" => 1320778862, value => "0.5" }, { "time" => 1320778922, value => "0.5" }, { "time" => 1320778982, value => "0.5" }, { "time" => 1320779162, value => "0.4" }, { "time" => 1320779222, value => "0.4" }, { "time" => 1320779342, value => "0.5" }, { "time" => 1320779403, value => "0.4" }, { "time" => 1320779461, value => "0.4" }, { "time" => 1320779522, value => "0.5" }, { "time" => 1320779582, value => "0.4" }, { "time" => 1320779642, value => "0.4" }, { "time" => 1320779702, value => "0.4" }, { "time" => 1320779762, value => "0.5" }, { "time" => 1320779822, value => "0.4" }, { "time" => 1320779882, value => "0.4" }, { "time" => 1320779941, value => "0.5" }, { "time" => 1320780002, value => "0.4" }, { "time" => 1320780062, value => "0.4" }, { "time" => 1320780123, value => "0.3" }, { "time" => 1320780182, value => "0.3" }, { "time" => 1320780242, value => "0.5" }, { "time" => 1320780302, value => "0.5" }, { "time" => 1320780362, value => "0.5" }, { "time" => 1320780422, value => "0.4" }, { "time" => 1320780482, value => "0.3" }, { "time" => 1320780542, value => "0.5" }, { "time" => 1320780662, value => "0.5" }, { "time" => 1320780722, value => "0.5" }, { "time" => 1320780782, value => "0.4" }, { "time" => 1320780843, value => "0.4" }, { "time" => 1320780901, value => "0.4" }, { "time" => 1320780962, value => "0.4" }, { "time" => 1320781022, value => "0.5" }, { "time" => 1320781082, value => "0.4" }, { "time" => 1320781142, value => "0.4" }, { "time" => 1320781202, value => "0.5" }, { "time" => 1320781262, value => "0.5" }, { "time" => 1320781322, value => "0.4" }, { "time" => 1320781382, value => "0.4" }, { "time" => 1320781442, value => "0.4" }, { "time" => 1320781502, value => "0.4" }, { "time" => 1320781562, value => "0.4" }, { "time" => 1320781622, value => "0.5" }, { "time" => 1320781681, value => "0.5" }, { "time" => 1320781742, value => "0.3" }, { "time" => 1320781802, value => "0.4" }, { "time" => 1320781862, value => "0.3" }, { "time" => 1320781922, value => "0.5" }, { "time" => 1320781982, value => "0.4" }, { "time" => 1320782042, value => "0.4" }, { "time" => 1320782102, value => "0.4" }, { "time" => 1320782162, value => "0.5" }, { "time" => 1320782222, value => "0.5" }, { "time" => 1320782283, value => "0.6" }, { "time" => 1320782342, value => "0.4" }, { "time" => 1320782403, value => "0.5" }, { "time" => 1320782461, value => "0.5" }, { "time" => 1320782522, value => "0.4" }, { "time" => 1320782582, value => "0.4" }, { "time" => 1320782642, value => "0.5" }, { "time" => 1320782703, value => "0.5" }, { "time" => 1320782761, value => "0.3" }, { "time" => 1320782822, value => "0.5" }, { "time" => 1320782882, value => "0.4" }, { "time" => 1320782942, value => "0.3" }, { "time" => 1320783003, value => "0.4" }, { "time" => 1320783062, value => "0.4" }, { "time" => 1320783122, value => "0.5" }, { "time" => 1320783182, value => "0.6" }, { "time" => 1320783242, value => "0.4" }, { "time" => 1320783302, value => "0.4" }, { "time" => 1320783362, value => "0.4" }, { "time" => 1320783422, value => "0.5" }, { "time" => 1320783481, value => "0.4" }, { "time" => 1320783542, value => "0.6" }, { "time" => 1320783602, value => "0.4" }, { "time" => 1320783722, value => "0.5" }, { "time" => 1320783782, value => "0.5" }, { "time" => 1320783842, value => "0.5" }, { "time" => 1320783902, value => "0.4" }, { "time" => 1320783962, value => "0.5" }, { "time" => 1320784022, value => "0.4" }, { "time" => 1320784082, value => "0.5" }, { "time" => 1320784142, value => "0.4" }, { "time" => 1320784202, value => "0.4" }, { "time" => 1320784262, value => "0.4" }, { "time" => 1320784322, value => "0.5" }, { "time" => 1320784382, value => "0.5" }, { "time" => 1320784441, value => "0.4" }, { "time" => 1320784502, value => "0.4" }, { "time" => 1320784562, value => "0.4" }, { "time" => 1320784622, value => "0.4" }, { "time" => 1320784682, value => "0.5" }, { "time" => 1320784742, value => "0.4" }, { "time" => 1320784802, value => "0.5" }, { "time" => 1320784862, value => "0.6" }, { "time" => 1320784922, value => "0.5" }, { "time" => 1320784982, value => "0.5" }, { "time" => 1320785042, value => "0.4" }, { "time" => 1320785102, value => "0.4" }, { "time" => 1320785162, value => "0.4" }, { "time" => 1320785222, value => "0.4" }, { "time" => 1320785283, value => "0.4" }, { "time" => 1320785341, value => "0.6" }, { "time" => 1320785402, value => "0.5" }, { "time" => 1320785462, value => "0.4" }, { "time" => 1320785522, value => "0.4" }, { "time" => 1320785582, value => "0.5" }, { "time" => 1320785643, value => "0.4" }, { "time" => 1320785702, value => "0.5" }, { "time" => 1320785762, value => "0.5" }, { "time" => 1320785822, value => "0.4" }, { "time" => 1320785882, value => "0.5" }, { "time" => 1320785942, value => "0.4" }, { "time" => 1320786002, value => "0.5" }, { "time" => 1320786062, value => "0.4" }, { "time" => 1320786122, value => "0.4" }, { "time" => 1320786182, value => "0.4" }, { "time" => 1320786242, value => "0.4" }, { "time" => 1320786303, value => "0.4" }, { "time" => 1320786362, value => "0.4" }, { "time" => 1320786422, value => "0.5" }, { "time" => 1320786482, value => "0.4" }, { "time" => 1320786542, value => "0.5" }, { "time" => 1320786602, value => "0.4" }, { "time" => 1320786662, value => "0.5" }, { "time" => 1320786722, value => "0.4" }, { "time" => 1320786782, value => "0.4" }, { "time" => 1320786842, value => "0.4" }, { "time" => 1320786902, value => "0.6" }, { "time" => 1320786962, value => "0.4" }, { "time" => 1320787022, value => "0.4" }, { "time" => 1320787082, value => "0.5" }, { "time" => 1320787142, value => "0.5" }, { "time" => 1320787202, value => "0.5" }, { "time" => 1320787262, value => "0.4" }, { "time" => 1320787322, value => "0.4" }, { "time" => 1320787381, value => "0.4" }, { "time" => 1320787442, value => "0.4" }, { "time" => 1320787502, value => "0.4" }, { "time" => 1320787561, value => "0.4" }, { "time" => 1320787622, value => "0.5" }, { "time" => 1320787682, value => "0.5" }, { "time" => 1320787742, value => "0.4" }, { "time" => 1320787802, value => "0.5" }, { "time" => 1320787862, value => "0.4" }, { "time" => 1320787922, value => "0.4" }, { "time" => 1320787982, value => "0.4" }, { "time" => 1320788042, value => "0.4" }, { "time" => 1320788102, value => "0.5" }, { "time" => 1320788162, value => "0.5" }, { "time" => 1320788222, value => "0.5" }, { "time" => 1320788282, value => "0.5" }, { "time" => 1320788342, value => "0.3" }, { "time" => 1320788402, value => "0.3" }, { "time" => 1320788462, value => "0.4" }, { "time" => 1320788522, value => "0.5" }, { "time" => 1320788581, value => "0.5" }, { "time" => 1320788642, value => "0.4" }, { "time" => 1320788702, value => "0.3" }, { "time" => 1320788762, value => "0.3" }, { "time" => 1320788822, value => "0.5" }, { "time" => 1320788882, value => "0.5" }, { "time" => 1320788942, value => "0.4" }, { "time" => 1320789002, value => "0.4" }, { "time" => 1320789062, value => "0.4" }, { "time" => 1320789122, value => "0.5" }, { "time" => 1320789182, value => "0.5" }, { "time" => 1320789242, value => "0.4" }, { "time" => 1320789302, value => "0.4" }, { "time" => 1320789422, value => "0.4" }, { "time" => 1320789482, value => "0.4" }, { "time" => 1320789543, value => "0.5" }, { "time" => 1320789602, value => "0.4" }, { "time" => 1320789662, value => "0.5" }, { "time" => 1320789722, value => "0.5" }, { "time" => 1320789782, value => "0.3" }, { "time" => 1320789842, value => "0.5" }, { "time" => 1320789903, value => "0.5" }, { "time" => 1320789962, value => "0.3" }, { "time" => 1320790022, value => "0.4" }, { "time" => 1320790083, value => "0.5" }, { "time" => 1320790143, value => "0.5" }, { "time" => 1320790262, value => "0.5" }, { "time" => 1320790322, value => "0.5" }, { "time" => 1320790382, value => "0.3" }, { "time" => 1320790442, value => "0.4" }, { "time" => 1320790502, value => "0.4" }, { "time" => 1320790562, value => "0.5" }, { "time" => 1320790622, value => "0.5" }, { "time" => 1320790683, value => "0.4" }, { "time" => 1320790742, value => "0.5" }, { "time" => 1320790802, value => "0.4" }, { "time" => 1320790862, value => "0.6" }, { "time" => 1320790922, value => "0.4" }, { "time" => 1320790982, value => "0.4" }, { "time" => 1320791042, value => "0.4" }, { "time" => 1320791102, value => "0.4" }, { "time" => 1320791162, value => "0.5" }, { "time" => 1320791222, value => "0.5" }, { "time" => 1320791281, value => "0.4" }, { "time" => 1320791342, value => "0.5" }, { "time" => 1320791403, value => "0.4" }, { "time" => 1320791462, value => "0.4" }, { "time" => 1320791522, value => "0.4" }, { "time" => 1320791582, value => "0.5" }, { "time" => 1320791642, value => "0.5" }, { "time" => 1320791703, value => "0.3" }, { "time" => 1320791762, value => "0.4" }, { "time" => 1320791822, value => "0.4" }, { "time" => 1320791883, value => "0.4" }, { "time" => 1320791942, value => "0.5" }, { "time" => 1320792001, value => "0.5" }, { "time" => 1320792062, value => "0.5" }, { "time" => 1320792122, value => "0.4" }, { "time" => 1320792182, value => "0.5" }, { "time" => 1320792242, value => "0.4" }, { "time" => 1320792302, value => "0.4" }, { "time" => 1320792363, value => "0.4" }, { "time" => 1320792422, value => "0.4" }, { "time" => 1320792482, value => "0.5" }, { "time" => 1320792542, value => "0.4" }, { "time" => 1320792602, value => "0.4" }, { "time" => 1320792662, value => "0.4" }, { "time" => 1320792723, value => "0.6" }, { "time" => 1320792781, value => "0.5" }, { "time" => 1320792842, value => "0.4" }, { "time" => 1320792902, value => "0.4" }, { "time" => 1320792962, value => "0.4" }, { "time" => 1320793022, value => "0.4" }, { "time" => 1320793082, value => "0.4" }, { "time" => 1320793142, value => "0.3" }, { "time" => 1320793202, value => "0.5" }, { "time" => 1320793262, value => "0.4" }, { "time" => 1320793322, value => "0.4" }, { "time" => 1320793382, value => "0.4" }, { "time" => 1320793443, value => "0.4" }, { "time" => 1320793502, value => "0.3" }, { "time" => 1320793562, value => "0.4" }, { "time" => 1320793622, value => "0.4" }, { "time" => 1320793683, value => "0.4" }, { "time" => 1320793742, value => "0.3" }, { "time" => 1320793802, value => "0.3" }, { "time" => 1320793862, value => "0.5" }, { "time" => 1320793922, value => "0.4" }, { "time" => 1320793982, value => "0.5" }, { "time" => 1320794042, value => "0.5" }, { "time" => 1320794102, value => "0.3" }, { "time" => 1320794162, value => "0.4" }, { "time" => 1320794222, value => "0.5" }, { "time" => 1320794282, value => "0.5" }, { "time" => 1320794342, value => "0.4" }, { "time" => 1320794402, value => "0.3" }, { "time" => 1320794462, value => "0.5" }, { "time" => 1320794522, value => "0.3" }, { "time" => 1320794582, value => "0.5" }, { "time" => 1320794643, value => "0.5" }, { "time" => 1320794702, value => "0.3" }, { "time" => 1320794762, value => "0.4" }, { "time" => 1320794822, value => "0.4" }, { "time" => 1320794882, value => "0.3" }, { "time" => 1320794942, value => "0.4" }, { "time" => 1320795002, value => "0.4" }, { "time" => 1320795062, value => "0.4" }, { "time" => 1320795122, value => "0.5" }, { "time" => 1320795182, value => "0.5" }, { "time" => 1320795242, value => "0.5" }, { "time" => 1320795302, value => "0.6" }, { "time" => 1320795361, value => "0.4" }, { "time" => 1320795422, value => "0.4" }, { "time" => 1320795482, value => "0.4" }, { "time" => 1320795542, value => "0.5" }, { "time" => 1320795602, value => "0.5" }, { "time" => 1320795662, value => "0.4" }, { "time" => 1320795722, value => "0.5" }, { "time" => 1320795782, value => "0.4" }, { "time" => 1320795842, value => "0.4" }, { "time" => 1320795902, value => "0.4" }, { "time" => 1320795963, value => "0.5" }, { "time" => 1320796022, value => "0.3" }, { "time" => 1320796082, value => "0.6" }, { "time" => 1320796143, value => "0.5" }, { "time" => 1320796203, value => "0.5" }, { "time" => 1320796263, value => "0.4" }, { "time" => 1320796382, value => "0.5" }, { "time" => 1320796622, value => "0.3" }, { "time" => 1320796682, value => "0.5" }, { "time" => 1320796743, value => "0.4" }, { "time" => 1320796861, value => "0.5" }, { "time" => 1320796922, value => "0.6" }, { "time" => 1320796982, value => "0.4" }, { "time" => 1320797042, value => "0.4" }, { "time" => 1320797103, value => "0.4" }, { "time" => 1320797162, value => "0.5" }, { "time" => 1320797222, value => "0.4" }, { "time" => 1320797282, value => "0.4" }, { "time" => 1320797342, value => "0.4" }, { "time" => 1320797462, value => "0.3" }, { "time" => 1320797523, value => "0.5" }, { "time" => 1320797582, value => "0.4" }, { "time" => 1320797642, value => "0.4" }, { "time" => 1320797702, value => "0.5" }, { "time" => 1320797762, value => "0.4" }, { "time" => 1320797822, value => "0.5" }, { "time" => 1320797882, value => "0.3" }, { "time" => 1320797942, value => "0.5" }, { "time" => 1320798002, value => "0.4" }, { "time" => 1320798061, value => "0.3" }, { "time" => 1320798122, value => "0.5" }, { "time" => 1320798182, value => "0.4" }, { "time" => 1320798243, value => "0.4" }, { "time" => 1320798302, value => "0.4" }, { "time" => 1320798362, value => "0.4" }, { "time" => 1320798422, value => "0.4" }, { "time" => 1320798482, value => "0.5" }, { "time" => 1320798542, value => "0.5" }, { "time" => 1320798603, value => "0.5" }, ); my $num; while ($num++ < scalar @dataset) { my @testdata = @dataset[0..$num]; say "Testing with " . scalar(@testdata) . " data points"; my $chart = Chart::Strip->new( title => 'Test case' ); $chart->add_data(\@testdata, { style => 'line' }); my $png = $chart->png; }
fixed. new version should show up on cpan shortly. thanks.
Great stuff, thanks! Just tried it out and works a treat now for all the periods I was trying to graph, even when a massive amount of datapoints are given :)


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.