Z
zhilianghu
A tutorial for using GD::Graph
(http://linuxgazette.net/issue83/padala.html) describes the input data
structure as:
my @data = (['Project', 'HW1', 'HW2', 'HW3', 'MidTerm', 'Final'],
[25, 6, 7, 2, 25, 35]);
In my program I constructed the data from internal associative array
as:
--1--
while (<HANDLE>) {
.... .......
$namess .= "'$key' ";
$values .= "$counts{$key} ";
}
$namess =~ s/\,$//g; # Take out the last comma
$values =~ s/\,$//g;
--2--
my @data = "([$namess],[$values])";
Although the print out of the "@data" structure appears the same as in
the example, the program complains: "Invalid data set: 0 at
/usr/local/apache/cgi-bin/treer line 153."
I also tried to use "push" at step "--1--", and/or use "qw" at step
"--2--", trying to make it an array but all failed the data demanded by
the next step ($myimage = $chart->plot(\@data)). I wonder what was the
problem? What the data structure in the example really ask for, and
the trick in producing such data structure in a dynamic way?
Thanks in advance for any kind advice!
Joe
(http://linuxgazette.net/issue83/padala.html) describes the input data
structure as:
my @data = (['Project', 'HW1', 'HW2', 'HW3', 'MidTerm', 'Final'],
[25, 6, 7, 2, 25, 35]);
In my program I constructed the data from internal associative array
as:
--1--
while (<HANDLE>) {
.... .......
$namess .= "'$key' ";
$values .= "$counts{$key} ";
}
$namess =~ s/\,$//g; # Take out the last comma
$values =~ s/\,$//g;
--2--
my @data = "([$namess],[$values])";
Although the print out of the "@data" structure appears the same as in
the example, the program complains: "Invalid data set: 0 at
/usr/local/apache/cgi-bin/treer line 153."
I also tried to use "push" at step "--1--", and/or use "qw" at step
"--2--", trying to make it an array but all failed the data demanded by
the next step ($myimage = $chart->plot(\@data)). I wonder what was the
problem? What the data structure in the example really ask for, and
the trick in producing such data structure in a dynamic way?
Thanks in advance for any kind advice!
Joe