#!/usr/bin/perl use strict; use GD::Graph::bars; use GD::Graph::lines; use GD::Graph::colour; use GD::Graph::Data; use CGI qw(:standard); use DBI; my $CGI = new CGI() or die("Unable to construct the CGI object" . ". Please contact the webmaster."); foreach ($CGI->param()) { $CGI->param($1,$CGI->param($_)) if (/(.*)\.x$/); } my $SiteName = $CGI->param('site') ; my $batchnumber = $CGI ->param('batchnumber')||"20170903nervana" ; my $dsn = "ddbi stuff"; my $usr = 'username'; my $password = 'pw'; my $dbh = DBI->connect($dsn,$usr,$password,{ RaiseError => 1}); my $sql = "SELECT time, mastuntemp, LineTemp, spargtemp FROM brew_temp_tb WHERE sitename = 'Brew' AND batchnumber = ? ORDER BY time"; print "DEBUG: \$sql = \"$sql\"\n"; my $sth = $dbh->prepare($sql); print "DEBUG: \$sth = \"$sth\"\n"; if (!$sth->execute($batchnumber)) { die "Error: ". $sth->errstr ."\n"; } my @row; my @row_array; my $data = GD::Graph::Data->new(600,500); $data->set( markers => [3, 5, 6] , dclrs => [ qw(green pink blue cyan) ], x_label => 'Time', y_label => 'Tempurature', title => "Batch $batchnumber Mashing Temperatures.", y_max_value => 180, y_tick_number => 8, y_label_skip => 2 ) or die $data->error; $data->set_legend('mashtontemp', 'LineTemp', 'spargtemp', my $recordidx = 0 ); while (@row = $sth->fetchrow_array) { print "DEBUG: \@row = \"@row\"\n"; #debug my $rowidx = 0; #degug foreach my $rowdata (@row) { #debug print " [$rowidx] = \"$rowdata\"\n";#debug $rowidx++; #debug print "DEBUG: \$data = \"$data\"\n";#debug }#debug print "DEBUG: \$data = \"$data\"\n";#debug print "record count $recordidx\n";#debug $data->add_point(@row); $recordidx++;#debug } print "DEBUG: \$data = \"$data\"\n";#debug my $chart = GD::Graph::lines->new(); my $gd = $chart->plot($data);