gary kuipers has asked for the wisdom of the Perl Monks concerning the following question:
The GD::Graph::Data manual states the following in the examples sectionmy $data = GD::Graph::Data->new(); my $graph = GD::Graph::bars->new(); my $format = $graph->export_format; if ( $dbh = DBI->connect("DBI:ODBC:$INI{DSN}",$INI{DBuser},$INI{DBp +ass}) ) { my $gotdata = 0; my $stmt = 'SELECT SysID FROM MeterEvent WHERE Sysid >= 2 and Sy +sid < = 10'; if ( my $sth = $dbh->prepare($stmt) ) { if ( my $rows = $sth->execute ) { while (my @row = $sth->fetchrow_array) { $data->add_point(@row); $gotdata = 1; } } } $dbh->disconnect(); } else { print "Database Error$br\n"; } my $gd = $graph->plot($data); open(IMG, '>file.gif') or die $!; binmode IMG; print IMG $gd->gif; # this is the line # 80 if ( defined $gd ) { print " 4.gd defined\n"; } else {print " 4.gd +NOT defined\n"; } close IMG;
Thanks for your help!use GD::Graph::Data; use GD::Graph::bars; my $data = GD::Graph::Data->new(); $data->read(file => '/data/sales.dat', delimiter => ','); $data = $data->copy(wanted => [2, 4, 5]); # Add the newer figures from the database use DBI; # do DBI things, like connecting to the database, statement # preparation and execution while (@row = $sth->fetchrow_array) { $data->add_point(@row); } my $chart = GD::Graph::bars->new(); my $gd = $chart->plot($data);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with references using GD::Graph::Data
by buckaduck (Chaplain) on Apr 01, 2002 at 18:56 UTC | |
by gary kuipers (Beadle) on Apr 01, 2002 at 22:09 UTC | |
|
Re: Problems with references using GD::Graph::Data
by metadoktor (Hermit) on Apr 01, 2002 at 18:49 UTC | |
|
Re: Problems with references using GD::Graph::Data
by mla (Beadle) on Apr 01, 2002 at 20:37 UTC |