I am trying to use perl's GD::graph to draw pie and bar in CGI program for wed browser. I have 2 example pl files which i could not get GD:graph to draw the pie and bar correctly. I have 6 values but i can only see 1 pie or 1 bar.
here is the code for pie:
use GD::Graph::pie;
use CGI;
my $q = new CGI;
my @col= {"1st","2nd","3rd","4th","5th","6th"};
my @val= {100,250,390,50,25,10};
my $graph = new GD::Graph::pie(500,500);
my @data = ([@col], [@val]);
$graph->set_label_font('ARIAL.TTF', 12);
$graph->set_value_font('ARIAL.TTF', 12);
$graph->set(
title => 'Performance Result',
label => 'Performance Result Pie',
axislabelclr => 'black',
pie_height => 36,
l_margin => 15,
r_margin => 15,
start_angle => 235,
transparent => 0,
dclrs => [qw(green pink cyan red yellow blue)],
show_values => 1,
);
print $q->header("image/gif");
binmode STDOUT;
print $graph->plot(\@data)->gif;
Here is the code for bar:
use GD::Graph::bars;
use CGI;
my $q = new CGI;
my @col= {"1st","2nd","3rd","4th","5th","6th"};
my @val= {150,250,390,50,25,10};
my $graph = new GD::Graph::bars(500,500);
my @data = ([@col],[@val]);
$graph->set(
title => 'Performance Result',
x_label => 'CPU #',
y_label => 'CPU %',
shadow_depth => 4,
shadowclr => 'dred',
transparent => 0,
dclrs => [qw (green pink cyan red yellow blue)],
show_values => 1,
);
print $q->header("image/gif");
binmode STDOUT;
print $graph->plot(\@data)->gif;
What have i missed in the script ?
I have tried both IE7 and Morzilla but got the same problem.
any help is appreciated.