in reply to GD @data array question
use strict; use warnings; use GD::Graph::bars; my @data; my $graph = GD::Graph::bars->new( 400, 300 ); for ( my $x=1; $x<10; $x++) { my @anotherarray=(1,2,3,4,5); push @data, [ @anotherarray ]; } my $gd = $graph->plot(\@data) or die $graph->error; open ( my $img, '>file.png') or die $!; binmode $img; print $img $gd->png; close $img;
The result is five groupings of 8 (not 9, check your loop counter) lines each in a vertical bar chart in a PNG file.
I'm not sure which portions are different from your entire program, because you provided only a particular portion. That portion may not be the one at fault after all. Be sure to post small yet functional code snippets for the best results. Also, I made what changes were necessary to use the strict and warnings pragmas. That's always a good idea.
Now that you've seen a working example using your own data structure, you should be able to start comparing things to figure out what else could be wrong.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: GD @data array question
by andy_7t (Novice) on Jan 29, 2009 at 22:08 UTC | |
by mr_mischief (Monsignor) on Jan 29, 2009 at 22:18 UTC | |
by ambrus (Abbot) on Jan 29, 2009 at 22:34 UTC | |
|
Re^2: GD @data array question
by andy_7t (Novice) on Jan 29, 2009 at 22:03 UTC | |
by mr_mischief (Monsignor) on Jan 29, 2009 at 22:05 UTC |