[Gllug] [Fwd: GD::Graph question]
Dean Wilson
dwilson at unixdaemon.net
Sun Nov 12 10:41:40 UTC 2006
On Sat, Nov 11, 2006 at 11:02:19PM +0000, Adrian McMenamin wrote:
> I asked this on the London perl mongers list and got no reply... I think
> it's a bit too specialist for here, but I thought I might as well try...
I love a challenge.
I've tweaked some chunks of it and this now works. Not sure it does exactly
what you want but you should be able to replace and test bits at a time
until it does.
------------------------------------------------
#!/usr/bin/perl -w
use strict;
use warnings;
use GD::Graph::lines;
$GD::Graph::Error::Debug = 5;
my $graph = GD::Graph::lines->new(400, 300)
or die GD::Graph->error;
$graph->set(title => 'title',
x_label => "X",
y_label => "Y",
) or die $graph->error;
my @data = ( [ 10, 20 ], [ 6, 8 ] );
my $gd_text = GD::Text->new();
# gdLargeFont should be a string. use strict caught this.
$graph->set_title_font('gdLargeFont', 18);
# your graph error checking was wrong, you were checking a variable.
my $gd = $graph->plot(\@data) or die $graph->error;
open(IMG, '>file.png') or die $!;
binmode IMG;
print IMG $gd->png;
exit(0);
------------------------------------------------
A couple of pointers, your script was too hard to test to see if I knew
what was wrong. I ripped out a load of variables and replaced them with
literals so I could reduce the size of the code that needed looking at.
I'm also pretty sure that you were running without strict and warnings. Bad
Adrian, Bad ;)
HTH
Dean
--
Dean Wilson http://www.unixdaemon.net
Profanity is the one language all programmers understand
--- Anon
-------------- next part --------------
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list