1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| #!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::Pane;
use Tk::Chart::Bars;
my $mw = MainWindow->new(
-title => 'Scrolled Graph',
-background => 'white',
);
my @x_label1 = map { $_ = "F$_" } ( 1 .. 30 );
my @x_label2 = map { $_ = "J$_" } ( 1 .. 30 );
my @data1 = map { $_ = rand(320) } ( 1 .. 60 );
my @data = ( [ @x_label1, @x_label2 ], [@data1], );
my @Legends = ('Donnees');
#===============================
# graphique sans redimensions
#===============================
my $chart = $mw->Bars(
-title => 'Mon graph sans scrolled',
-xlabel => 'X Label',
-ylabel => 'Y Label',
-background => 'snow',
)->pack;
$chart->enabled_gradientcolor();
# Add a legend to the graph
$chart->set_legend(
-title => 'Ma legend',
-data => \@Legends,
-titlecolors => 'blue',
);
# Add help identification
$chart->set_balloon();
# Create the graph
$chart->plot( \@data );
#===============================
# graphique avec redimensions
#===============================
my $pane = $mw->Scrolled(
'Pane',
-scrollbars => 'osoe',
-sticky => 'nswe',
);
$pane->Frame;
$pane->pack(qw / -fill both -expand 1 -pady 20 /);
my $chart2 = $pane->Bars(
-title => 'Mon graph avec scrolled',
-titleposition => 'left',
-xlabel => 'X Label',
-ylabel => 'Y Label',
-background => 'snow',
-width => 3000,
)->pack(qw / -fill both -expand 1 /);
$chart2->enabled_gradientcolor();
# Add a legend to the graph
$chart2->set_legend(
-title => 'Ma legend',
-data => \@Legends,
-titlecolors => 'blue',
);
# Add help identification
$chart2->set_balloon();
# Create the graph
$chart2->plot( \@data );
MainLoop(); |
Partager