Thank you so much again for your help! Code as follows:
#!/usr/bin/perl use CGI ':standard'; use GD::Graph::lines; use DBI; use Data::Dumper; use Mysql; $inint = "1"; $result = "sum(octets)"; my $dbh = Mysql->connect('localhost','pzbg001','root','xxxxxxx'); @dates = $dbh->ListTables; # query each table for sum of traffic, # push table_name (i.e. date) and traffic sum onto @data: my @data = (); for my $date ( @dates ) { my $dbh = DBI->connect('DBI:mysql:pzbg001', 'root', 'xxxxxxx', {Ra +iseError => 1}); my $query = "select $result from $date where inintf=$inint"; my $sth = $dbh->prepare($query); if (!$sth) { die "Illegal query: $query" }; $sth->execute; my $octets = ($sth->fetchrow_array)[0]; # don't chomp it! $sth->finish; push (@total, $octets/(1024*1024)); } my @data = ( \@dates, \@total); ##################### my $mygraph = GD::Graph::lines->new(600, 300); $mygraph->set( x_label => 'Date', y_label => 'Kb of Traffic', title => 'Traffic for $router ', # Draw datasets in 'solid', 'dashed' and 'dotted-dashed' lines line_types => [1], # Set the thickness of line line_width => 2, # Set colors for datasets dclrs => ['blue'], ) or warn $mygraph->error; $mygraph->set_legend_font(GD::gdMediumBoldFont); $mygraph->set_legend('Total'); my $myimage = $mygraph->plot(\@data) or die $mygraph->error; print "Content-type: image/png\n\n"; print $myimage->png;
Baiul
Ubi Concordia Ibi Victoria
In reply to Re: Re: Re: Re: Re: GD::Graph::lines problem!
by Baiul
in thread GD::Graph::lines problem!
by Baiul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |