andy_7t has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to create a dynamic set of arrays to pipe into GD::Graph.
This works fine:
My question: How do i make @data have X set of arrays.@data=([@array1],[@array2],[@array3]); my $gd = $graph->plot(\@data) or die $graph->error;
e.g.
which should give 9 lines?for ($x=1; $x<10; $x++) { @anotherarray=(1,2,3,4,5); push @data, [ @anotherarray ]; } my $gd = $graph->plot(\@data) or die $graph->error;
I just get no points defined, or more specifically: No data sets or points :-(
UPDATE:
I'll give full details of what i'm trying to do.
It's basically a traffic graph from multiple flat text files representing data streams.
They are in the format
TIME(HH:MM:SS):KBITS
I open each file:
foreach $file (@files) { undef @timestamp; undef @kbits; open FILE, "$file"; @points=<FILE>; foreach $point (@points) { @split=split /:/, $point; push @timestamp, $split[0]; push @kbits, $split[1]; #### NOW IDEALLY, I WANT TO ADD @kbits TO THE DATA SET ### something like this: push (@data, [ @kbits ] ); #forget the timestamp for now- that just c +omplicates matters! } ## BUT I CAN'T, SO I JUST CURRENTLY TAKE THE LAST SET OF DATA # this gives no error @data=([@timestamp],[@kbits]); I'm using fatalstobrowser so the exact error is: No data sets or points at /home/web/http/volgraph.pl line 250. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GD @data array question
by mr_mischief (Monsignor) on Jan 29, 2009 at 21:58 UTC | |
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 | |
by andy_7t (Novice) on Jan 29, 2009 at 22:03 UTC | |
by mr_mischief (Monsignor) on Jan 29, 2009 at 22:05 UTC |