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
| use strict;
use warnings;
use Tk;
use Tk::Chart::Mixed;
my $mw = MainWindow->new(
-title => 'Tk::Chart::Mixed',
-background => 'white',
);
my @types = ( 'areas', 'bars', 'lines', 'points', 'bars', 'dashlines' );
my $chart = $mw->Mixed(
-title => 'Tk::Chart::Mixed',
-xlabel => 'X Label',
-ylabel => 'Y Label',
-background => '#D0D0FF',
-linewidth => 2,
-typemixed => \@types,
-markers => [ 3, 5, 6 ],
-longticks => 1,
)->pack(qw / -fill both -expand 1 /);
my @data = (
[ '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th' ],
[ 90, 29, 25, 6, -20, 1, 1, 3, 4 ],
[ 15, 10, 5, 2, 3, 5, 7, 9, 12 ],
[ 1, 2, 12, 6, 3, 5, 1, 23, 5 ],
[ 15, 12, 24, 33, 19, 8, 6, 15, 21 ],
[ 15, 2, 52, 6, 3, 17.5, 1, 43, 10 ],
[ 30, 2, 5, 6, 3, 1.5, 1, 3, 4 ],
[ 24, 12, 35, 20, 13, 31.5, 41, 6, 25 ],
);
# Add a legend to the graph
my @legends = @types;
$chart->set_legend(
-title => "Title legend",
-data => [ 'legend 1', 'legend 2', 'legend 3', 'legend 4', 'legend 5', 'legend 6', 'legend 7', ],
-titlecolors => "blue",
);
# Add help identification
$chart->set_balloon();
# Create the graph
$chart->plot( \@data );
# background order wanted
$chart->display_order( [qw/ areas lines bars dashlines points /] );
MainLoop(); |
Partager