#!C:\perl\bin\perl.exe use strict; use warnings; use CGI ':standard'; use GD::Graph::lines; use GD::Graph::Map; use DBI; use Data::Dumper; my $db = "..."; my $user = "..."; my $pwd = "..."; my $dbh = DBI->connect("DBI:DB2:$db", "$user", "$pwd", {RaiseError => 0, AutoCommit => 1}); my $stmt = "..."; my $sth = $dbh->prepare($stmt); my $rc = $sth->execute; my $data = $sth->fetchall_arrayref; $sth->finish; my @dates = (); my @values = (); my @urls = (); my $baseURL = "http://localhost:8080/cgi-bin/index.cgi?date="; foreach my $entry (@$data){ push(@dates, $entry->[0]); push(@values, $entry->[1]); push(@urls, $baseURL . $entry->[0]); } my @chartData = ([@dates], [@values]); my $graph = GD::Graph::lines->new(1300, 600); $graph->set( x_label => 'Date', y_label => 'Transaction Count', title => 'Transaction Counts by Day', y_max_value => 2500, y_min_value => 0, y_tick_number => 10, y_label_skip => 2, box_axis => undef, line_width => 2, ); open(CHART, ">../htdocs/chart.png") or die; binmode CHART; print CHART $graph->plot(\@chartData)->png; close(CHART); my $map = new GD::Graph::Map($graph, hrefs=>\@urls, noImgMarkup=>0, mapName=>"chartmap", info=>'%x,%y', ); print header, start_html('Simple Script'), h1('Simple Script'), hr, img({src=>"/chart.png", usemap=>"#chartmap"}), ($map->imagemap("chart.png", \@chartData)); print end_html; print Dumper @dates; print Dumper @values; print Dumper @urls; #### Simple Script

Simple Script


%x,%y $VAR1 = '2009-06-01'; $VAR2 = '2009-06-02'; $VAR3 = '2009-06-03'; $VAR4 = '2009-06-04'; $VAR5 = '2009-06-05'; $VAR6 = '2009-06-06'; $VAR7 = '2009-06-07'; $VAR8 = '2009-06-08'; $VAR9 = '2009-06-09'; $VAR10 = '2009-06-10'; $VAR11 = '2009-06-11'; $VAR12 = '2009-06-12'; $VAR13 = '2009-06-13'; $VAR14 = '2009-06-14'; $VAR15 = '2009-06-15'; $VAR16 = '2009-06-16'; $VAR17 = '2009-06-17'; $VAR18 = '2009-06-18'; $VAR19 = '2009-06-19'; $VAR20 = '2009-06-20'; $VAR21 = '2009-06-21'; $VAR22 = '2009-06-22'; $VAR23 = '2009-06-23'; $VAR24 = '2009-06-24'; $VAR25 = '2009-06-25'; $VAR26 = '2009-06-26'; $VAR27 = '2009-06-27'; $VAR28 = '2009-06-28'; $VAR29 = '2009-06-29'; $VAR30 = '2009-06-30'; $VAR1 = '612'; $VAR2 = '1099'; $VAR3 = '842'; $VAR4 = '899'; $VAR5 = '1016'; $VAR6 = '567'; $VAR7 = '504'; $VAR8 = '654'; $VAR9 = '665'; $VAR10 = '1085'; $VAR11 = '871'; $VAR12 = '1120'; $VAR13 = '1174'; $VAR14 = '929'; $VAR15 = '1047'; $VAR16 = '1118'; $VAR17 = '1008'; $VAR18 = '954'; $VAR19 = '729'; $VAR20 = '574'; $VAR21 = '534'; $VAR22 = '668'; $VAR23 = '1292'; $VAR24 = '965'; $VAR25 = '880'; $VAR26 = '727'; $VAR27 = '689'; $VAR28 = '470'; $VAR29 = '582'; $VAR30 = '852'; $VAR1 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-01'; $VAR2 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-02'; $VAR3 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-03'; $VAR4 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-04'; $VAR5 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-05'; $VAR6 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-06'; $VAR7 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-07'; $VAR8 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-08'; $VAR9 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-09'; $VAR10 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-10'; $VAR11 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-11'; $VAR12 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-12'; $VAR13 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-13'; $VAR14 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-14'; $VAR15 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-15'; $VAR16 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-16'; $VAR17 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-17'; $VAR18 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-18'; $VAR19 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-19'; $VAR20 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-20'; $VAR21 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-21'; $VAR22 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-22'; $VAR23 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-23'; $VAR24 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-24'; $VAR25 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-25'; $VAR26 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-26'; $VAR27 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-27'; $VAR28 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-28'; $VAR29 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-29'; $VAR30 = 'http://localhost:8080/cgi-bin/index.cgi?date=2009-06-30';