
#!/usr/bin/perl -w
$++;
use strict;
use GD::Graph::bars;
#Following data illustrated on GD::Graph module
my @data = ( ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
[ sort { $a <=> $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ] );
my $graph = GD::Graph::bars->new(300, 200);
$graph->set( x_label => 'X Label',
y_label => 'Y label',
title => 'Some simple graph',
y_max_value => 8,
y_tick_number => 8,
y_label_skip => 2 );
my $gd = $graph->plot(\@data);
print "content-type: image/png\n\n";
binmode STDOUT;
print $gd->png;
This should have created a nice graph line chart.
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
[ sort { $a <=> $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ] );
my $graph = GD::Graph::bars->new(300, 200);
$graph->set( x_label => 'X Label',
y_label => 'Y label',
title => 'Some simple graph',
y_max_value => 8,
y_tick_number => 8,
y_label_skip => 2 );
my $gd = $graph->plot(\@data);
print "content-type: image/png\n\n";
binmode STDOUT;
print $gd->png;
This should have created a nice graph line chart.
See the script in action at my web page

No comments:
Post a Comment