Академический Документы
Профессиональный Документы
Культура Документы
GD::Graph
GD::Graph adalah perluasan dari GD module yang
menyediakan API untuk membuat graph dan
chart secara on-the-fly.
GD::Graph dirancang oleh Martien Verbruggen in
1995 dan terus berkembang menjadi tool yang
popular.
Modul ini sangat cocok dipadukan dengan dataset
yang dinamis (dari database). Saat ini, GD::Graph
menjadi tool untuk menampilkan chart dan graph
terkait keuangan (finansial)
Setup Awal
Install
- libgd-text-perl
Referensi:
http://search.cpan.org/~mverb/GDGraph1.43/Graph.pm
Bar Chart
#!/usr/bin/perl
use CGI;
use strict;
use GD::Graph::bars;
my @data = (
["Jan-01","Feb-01","Mar-01", "Apr-01","May-01",
"Jun-01","Jul-01","Aug-01","Sep-01"],
[21,25,33,39,49,48,40,45,15]
);
my $cgi = CGI->new;
my $graph = new GD::Graph::bars;
CGI;
strict;
GD::Graph::bars;
GD::Graph::hbars;
GD::Graph::Data;
my $data = GD::Graph::Data->new([
["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
]) or die GD::Graph::Data->error;
my @names = qw/sample11 sample11-h/;
my $cgi = CGI->new;
print $cgi->header({-type=>'text/html'});
print $cgi->start_html({-title=>"Grafika Komputer",
-style=>{-src=>'tfa.css'}});
CGI;
strict;
GD::Graph::bars;
GD::Graph::hbars;
GD::Graph::Data;
my $data = GD::Graph::Data->new([
["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
]) or die GD::Graph::Data->error;
my @names = qw/sample11 sample11-h/;
my $cgi = CGI->new;
print $cgi->header({-type=>'text/html'});
print $cgi->start_html({-title=>"Grafika Komputer",
-style=>{-src=>'tfa.css'}});
sub display_chart(){
my $file = shift;
my $path = "http://localhost/tmp/$file";
print $cgi->img({-src=>"$path", -class=>'gambar'});
print $cgi->br x 3;
}
http://gdgraph.com/samples/