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