Tk-Chart

 view release on metacpan or  search on metacpan

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

package Tk::Chart::Pie;

use warnings;
use strict;
use Carp;

#==================================================================
# $Author    : Djibril Ousmanou                                   $
# $Copyright : 2018                                               $
# $Update    : 09/02/2018                                         $
# $AIM       : Create pie graph                                   $
#==================================================================

use vars qw($VERSION);
$VERSION = '1.06';

use base qw/ Tk::Derived Tk::Canvas::GradientColor /;
use Tk::Balloon;

use Tk::Chart::Utils qw / :DUMMIES /;
use Tk::Chart qw / :DUMMIES /;

Construct Tk::Widget 'Pie';

sub Populate {

  my ( $cw, $ref_parameters ) = @_;

  # Get initial parameters
  $cw->{RefChart} = $cw->_initconfig();

  $cw->SUPER::Populate($ref_parameters);

  $cw->Advertise( 'GradientColor' => $cw );
  $cw->Advertise( 'canvas'        => $cw->SUPER::Canvas );
  $cw->Advertise( 'Canvas'        => $cw->SUPER::Canvas );

  # remove highlightthickness if necessary
  if ( !exists $ref_parameters->{-highlightthickness} ) {
    $cw->configure( -highlightthickness => 0 );
  }

  # ConfigSpecs
  $cw->ConfigSpecs(
    -title         => [ 'PASSIVE', 'Title',         'Title',         undef ],
    -titlecolor    => [ 'PASSIVE', 'Titlecolor',    'TitleColor',    'black' ],
    -titlefont     => [ 'PASSIVE', 'Titlefont',     'TitleFont',     $cw->{RefChart}->{Font}{DefaultTitle} ],
    -titleposition => [ 'PASSIVE', 'Titleposition', 'TitlePosition', 'center' ],
    -width         => [ 'SELF',    'width',         'Width',         $cw->{RefChart}->{Canvas}{Width} ],
    -height        => [ 'SELF',    'height',        'Height',        $cw->{RefChart}->{Canvas}{Height} ],

    -linewidth  => [ 'PASSIVE', 'Linewidth',  'LineWidth',  2 ],
    -startangle => [ 'PASSIVE', 'Startangle', 'StartAngle', 0 ],
    -colordata  => [ 'PASSIVE', 'Colordata',  'ColorData',  $cw->{RefChart}->{Legend}{Colors} ],

    -legendcolor => [ 'PASSIVE', 'Legendcolor', 'LegendColor', 'black' ],
    -setlegend   => [ 'PASSIVE', 'Setlegend',   'SetLegend',   1 ],
    -piesize     => [ 'PASSIVE', 'Piesize',   'PieSize',   360 ],

	-legendfont => [ 'PASSIVE', 'Legendfont',  'LegendFont',  $cw->{RefChart}->{Legend}{legendfont} ],
	
    # verbeose mode
    -verbose => [ 'PASSIVE', 'verbose', 'Verbose', 1 ],
  );

  $cw->Delegates( DEFAULT => $cw, );

  # recreate graph after widget resize
  $cw->enabled_automatic_redraw();
  $cw->disabled_gradientcolor();
}

sub plot {
  my ( $cw, $ref_data ) = @_;

  if ( not defined $ref_data ) {
    $cw->_error('data not defined');



( run in 0.483 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )