loader image Authenticating...

How to create bar chart in perl

by kalai 2008-12-10 19:53:57


#!D:\Perl\bin\perl
# Change above line to point to your perl binary

use CGI ':standard';
use GD::Graph::bars;
use strict;

my @data = (['Berlin', 'Paris', 'Rome', 'London', 'Munich'],
[80, 90, 85, 75],
[76, 55, 75, 95],
[66, 58, 92, 83],
[80, 90, 85, 75],
[76, 55, 75, 95],
[66, 58, 92, 83],
);

my $g = GD::Graph::bars->new(500, 300);



my %hash = ('title' => 'Sold Cars in 2001',
'text_space' => 5,
'grey_background' => 'false',
'integer_ticks_only' => 'true',
'x_label' => 'City',
'y_label' => 'Number of Cars',
'legend' => 'bottom',
'legend_labels' => ['January' , 'February' , 'March', 'April',
'May', 'June', 'July', 'August', 'September',
'October', 'November', 'December'],
'min_val' => 0,
'max_val' => 20,
'grid_lines' =>'true',
'colors' => {'title' => 'red',
'x_label' => 'blue',
'y_label' => 'blue'} );
$g->set (%hash);
my $myimage = $g->plot(@data) or die $g->error;

print "Content-type: image/png";
print $myimage->png;


Tagged in:

781
like
0
dislike
0
mail
flag

You must LOGIN to add comments