Subject: | Ballon not refreshed |
Date: | Sun, 23 Apr 2017 18:04:46 +0200 |
To: | bug-Tk-Chart [...] rt.cpan.org |
From: | Andrea Nugnes <andrea.nugnes [...] gmail.com> |
Dears
I’ve a problem to make a refresh of the graphical chart
I’m using Tk::Chart::Pie version 1.18
The Perl version I’m using is 5.24.1 on Mac OS X 10 El Capitan
Here is my example:
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::Chart::Pie;
my $message;
my $Received = 0;
my $Sent = 0;
my $Incomplete = 0;
my $mw = MainWindow->new( -title => 'Patient Status', );
my $GraphFrame = $mw->Frame( -label => 'Graph', -borderwidth =>4, -relief => 'groove');
my $chart = $GraphFrame->Pie(
-title => 'Patient Status Frame',
-background => 'white',
-linewidth => 2,
)->pack(qw / -fill both -expand 1 /);
my @data = ( [ 'Received', 'Sent', 'Incomplete' ], [ 3,3,4 ], );
my $bottomFrame = $mw->Frame( -label => 'Commands', -borderwidth => 4, -relief => 'raised');
my $quitButton = $bottomFrame->Button( -text => 'Quit', -command => \&exitProgram);
my $infoPane = $bottomFrame->Label( -anchor =>'center', -textvariable => \$message, -borderwidth => 2, -relief => 'groove');
my $startStopButton = $bottomFrame->Button( -text => 'Start / Stop', -command => \&randomizePatients);
$GraphFrame -> pack( -anchor => 'n', -side => 'top', -fill => 'x');
$bottomFrame -> pack( -anchor => 's', -side => 'bottom', -fill => 'x');
$quitButton -> pack( -anchor => 's', -side => 'bottom', -fill => 'x');
$infoPane -> pack( -anchor => 's', -side => 'bottom', -fill => 'x');
$startStopButton -> pack( -anchor => 's', -side => 'bottom', -fill => 'x');
#~ $chart->plot( \@data );
MainLoop();
sub randomizePatients(){
$Received = rand(10);
$Sent = rand(10);
$Incomplete = rand(10);
$message = 'Received='.$Received.' | Sent='.${Sent}.' | Incomplete='.${Incomplete};
@data = ( [ 'Received', 'Sent', 'Incomplete' ], [$Received, $Sent, $Incomplete], );
$chart->clearchart();
$chart->plot(\@data);
$chart->redraw();
}
The problem is that after refreshing the chart with new data, the balloons are reporting always the first data when the chart was created.
Is there any way to change this?
Many thanks in advance
Regards
Andrea Nugnes
andrea.nugnes@gmail.com