Skip Menu |

This queue is for tickets about the Chart CPAN distribution.

Report information
The Basics
Id: 8874
Status: new
Priority: 0/
Queue: Chart

People
Owner: Nobody in particular
Requestors: support [...] infortech.ru
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 2.2
  • 2.3
Fixed in: (no value)



Subject: Zeroes in data causes Chart::Pie fails with "division by zero"
:)
--- ./Pie.pm Thu Dec 4 18:09:28 2003 +++ /usr/lib/perl5/site_perl/5.005/Chart/Pie.pm Tue Dec 14 15:29:25 2004 @@ -762,7 +762,7 @@ if(defined $self->{'label_values'}) { if($self->{'label_values'} =~ /^percent$/i) { - $label = sprintf("%s %4.2f%%",$label, $data->[1][$j] / $dataset_sum * 100); + $label = sprintf("%s %4.2f%%",$label, $data->[1][$j] / ($dataset_sum || 1) * 100); } elsif($self->{'label_values'} =~ /^value$/i) { @@ -804,7 +804,7 @@ # the final pie slice will end at 360 degrees. # So, get the degree offset for this dataset - $end_degrees = $start_degrees + ($data->[1][$j] / $dataset_sum * 360); + $end_degrees = $start_degrees + ($data->[1][$j] / ($dataset_sum || 1) * 360); # stick the label in the middle of the slice $label_degrees = ($start_degrees + $end_degrees) / 2;