Skip Menu |

This queue is for tickets about the Imager-Graph CPAN distribution.

Report information
The Basics
Id: 34813
Status: resolved
Priority: 0/
Queue: Imager-Graph

People
Owner: TONYC [...] cpan.org
Requestors: hussainpithawala [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.05
Fixed in: 0.05



Subject: Graph Plotting failure
Whenever data supplied to plot the graph is having no values in the others segment( or simply if others, as deemed by maxsegment is having no value), the graph is plotted with the color chosen for others only and no segments could be identified. I had found a simple remedy for this problem by changing the behaviour of the subroutine _consolidate_segments a bit. Here are the versions. ######### Version 0.05 ########### sub _consolidate_segments { my ($self, $data, $labels, $total) = @_; my @others; my $index; for my $item (@$data) { if ($item / $total < $self->{_style}{pie}{maxsegment}) { push(@others, $index); } ++$index; } my $others_value = 0; if (@others) { for my $index (reverse @others) { $others_value += $data->[$index]; splice(@$labels, $index, 1); splice(@$data, $index, 1); } push(@$labels, $self->{_style}{otherlabel}) if @$labels; push(@$data, $others_value); } } #################### Bug Fix ################ sub _consolidate_segments { my ($self, $data, $labels, $total) = @_; my @others; my $index; for my $item (@$data) { if ($item / $total < $self->{_style}{pie}{maxsegment}) { push(@others, $index); } ++$index; } my $others_value = 0; if (@others) { for my $index (reverse @others) { $others_value += $data->[$index]; splice(@$labels, $index, 1); splice(@$data, $index, 1); } push(@$labels, $self->{_style}{otherlabel}) if @$labels; if($others_value){ push(@$data, $others_value); } } } ##################################################### It just pulls out the other segment from the data Array.Also I request to change the "maxsegment" value to 0.01 instead of 0.05. With Warm Regards hussa
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #34813] Graph Plotting failure
Date: Fri, 11 Apr 2008 09:41:25 +1000
To: Hussain via RT <bug-Imager-Graph [...] rt.cpan.org>
From: tonyc [...] cpan.org
On Thu, Apr 10, 2008 at 02:20:15AM -0400, Hussain via RT wrote: Show quoted text
> Whenever data supplied to plot the graph is having no values in the > others segment( or simply if others, as deemed by maxsegment is having > no value), the graph is plotted with the color chosen for others only > and no segments could be identified. > > I had found a simple remedy for this problem by changing the behaviour > of the subroutine _consolidate_segments a bit. Here are the versions.
... Show quoted text
> It just pulls out the other segment from the data Array.Also I request > to change the "maxsegment" value to 0.01 instead of 0.05.
Thanks for this, I have one other change in progress for Imager::Graph, I'll integrate this into the same release. I'll change the maxsegment default too, since you're not the only who has asked - but you may not be aware that you can override this when creating the graph: my $img = $chart->draw ( ... pie => { maxsegment => 0.01 }, ); Tony
On Thu Apr 10 02:20:14 2008, hussa wrote: Show quoted text
> It just pulls out the other segment from the data Array.Also I request > to change the "maxsegment" value to 0.01 instead of 0.05.
Hi, I've handled this a bit differently. The problem only occurs when the segment size is zero, I couldn't get it to occur with very small segments, and your change doesn't try to handle very small segments. Instead of completely removing the empty segment, I've changed the code to simply not fill them. Tony
I've released Imager-Graph 0.06 which fixes this problem. Tony