Chart-ThreeD

 view release on metacpan or  search on metacpan

lib/Chart/ThreeD/Pie.pm  view on Meta::CPAN

sub initialize {
  my $self = shift;

  $self->{xmax}  = shift || 400;
  $self->{ymax}  = shift || 300;
  $self->{title} = shift || '';
  $self->{data}  = [];
  $self->{bgcolor} = '#FFFFFF';
  $self->{fgcolor} = '#000000';
  $self->{limit} = [ 7, '#FF0000', 'others' ];
  $self->{transparent} = 0;
  $self->{interlaced} = 0;
  $self->{thickness} = 30; # pixels
  $self->{radius} = $self->{xmax} / 3;
  $self->{want_sort} = 0;
  $self->{border} = 0;
  $self->{percents} = 0;
}

=head2 Commands

lib/Chart/ThreeD/Pie.pm  view on Meta::CPAN


=cut

sub want_sort {
  my $self = shift;
  my $arg  = shift;
  $self->{want_sort} = $arg if defined $arg;
  return $self->{want_sort};
}

=item C<transparent>

C<Chart::ThreeD::Pie::transparent(bool)> I<object method>

This will allow you to make the background of the final picture transparent
if bool is non-null. The current value is returned. Default is null;

Example:

      # Background will be transparent.
      $pie->transparent(1);

=cut

sub transparent {
  my $self = shift;
  my $arg  = shift;
  $self->{transparent} = $arg if defined $arg;
  return $self->{transparent};
}

=item C<interlaced>

C<Chart::ThreeD::Pie::interlaced(bool)> I<object method>

This will allow you to make the background of the final picture interlaced
if bool is non-null. The current value is returned. Default is null;

Example:

lib/Chart/ThreeD/Pie.pm  view on Meta::CPAN


sub plot {
  my $self = shift;

  my $pie = new GD::Image($self->xmax, $self->ymax);

  my $fontw = gdSmallFont->width;
  my $fonth = gdSmallFont->height;

  my $bgcolor = $pie->colorAllocate (&cvtcolor ($self->bgcolor));
  $pie->transparent ($bgcolor) if $self->transparent;
  $pie->fill (0, 0, $bgcolor);
  my $total = 0;
  map { $total += $$_[0] } @{$self->{data}};

  my $fgcolor = $pie->colorAllocate (&cvtcolor ($self->fgcolor));
  my $defaultcolor = $pie->colorAllocate (&cvtcolor (${$self->limit}[1]));
  my $defaultcolor2 = $pie->colorAllocate
    (&shadecolor (&cvtcolor (${$self->limit}[1])));

  my $orgx = $self->xmax / 2;



( run in 0.533 second using v1.01-cache-2.11-cpan-0a6323c29d9 )