User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion > Hardware and Tech Support

Reply
Thread Tools Display Modes
Unread 27 Apr 2006, 13:13   #1
Appocomaster
PA Team
 
Appocomaster's Avatar
 
Join Date: Oct 2003
Posts: 7,449
Appocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus would
perl GD::graph etc

As I posted on GD, i'm doing my final year project.
I have a perl script that's meant to go through a couple of nested loops plotting lots of data and filling up a mysql table.

mysql> describe daisyworld_tbl;
Code:
+-------------+-------+------+-----+---------+-------+
| Field       | Type  | Null | Key | Default | Extra             |
+-------------+-------+------+-----+---------+-------+
| L           | float | YES  |     | NULL    |       |
| areawhite   | float | YES  |     | NULL    |       |
| areablack   | float | YES  |     | NULL    |       |
| temperature | float | YES  |     | NULL    |       |
+-------------+-------+------+-----+---------+-------+
my perl script includes:
Code:
use GD::Graph::bars;
$dbh stuff...
loop with this code in it: 
$sth=$dbh->prepare("insert into daisyworld_tbl VALUES ('$Lcurrent','$whiteground','$blackground','$emittedtemperature')");
 $sth->execute();
....
my $graph = GD::Graph::bars->new( 800, 600 ); 
 $graph->set( title   => "Daisyworld",
           y_label => "Temperature" );
my $sth = $dbh->prepare("select L from daisyworld_tbl");
my @xvariables = fetch_data($sth);
$sth = $dbh->prepare("select temperature from daisyworld_tbl");
my @yvariables = fetch_data($sth);
my @data     = (\@xvariables,\@yvariables);
my $image = $graph->plot( \@data ) or die( "Cannot create image" );
open( OUT, "| display -") or die( "Cannot display image: $!" );
binmode OUT;
print OUT $image->png();
close OUT;
#I got the above by stealing from some site after googling:
#my $graph = GD::Graph::bars->new( 800, 600 ); 
#my @xLabels  = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
#my @datatemp = qw(  17  19  26  38  56  64  67  53  40  29  21  13 );
#my @data     = ( \@xLabels, \@data2002);
#
#
#$graph->set( title   => "Rainfall 2002/2003",
#            y_label => "Millimetres" );
#
#my $image = $graph->plot( \@data ) or die( "Cannot create image" );
#
#open( OUT, "| display -") or die( "Cannot display image: $!" );
#  binmode OUT;
#print OUT $image->png();
#close OUT;
I want to plot L vs temperature from the mysql table (L x variable, T y variable).

Apart from the fact that the numbers keep breaking the database (I keep getting errors because I've obviously messed up the code somewhere)
getting the graph plotted isn't too easy either

I get this error via apache:
[Thu Apr 27 13:08:09 2006] [error] Can't locate object method "new" via package "GD::Graph::bars" at Daisyworld2.pl line 133.\n

however, opening C:\perl\site\lib\gd\graph\bars.pm gives me
sub new
{
my $class = shift;
my $context = shift;
return $class->SUPER::new(@_);
}

any ideas how to fix this error, and will my graph actually plot when the error is fixed (assuming that I get through calcuating the numbers ok) ?
__________________
r8-10 RaH r10.5-12 MISTU
Appocomaster is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 16:51.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018