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.
In reply to Re: GD @data array question
by mr_mischief
in thread GD @data array question
by andy_7t
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |