in reply to draw picture by google Chart
There's a lot about your post I don't understand, and I have no experience whatever with the URI::GoogleChart module, but I have never thought that mere ignorance should prevent one from offering advice, so here goes.
First off, I assume the
statement works as it stands (possibly an example from documentation), and your problem is to use different data than 45, 80, 55, 68.my $chart = URI::GoogleChart->new("lines", 300, 100, data => [45, 80, 55, 68], range_show => "left", range_round => 1, );
... my data is an array or array_ref without comma, like: @a = (1 2 3 4) ...
As you have seen, this doesn't work because it is syntactically incorrect. The correct assignment expression would be @a = (1, 2, 3, 4) or perhaps a statement like
my @a = (1, 2, 3, 4);
if one were defining a lexical array (see my) and initializing it. The quick fix is to put in the needed commas.
But I suspect the quick fix doesn't work because your data is not in the form of a list, but rather is a string consisting of numbers with whitespace separating the numbers, something like "1 2 3 4" (with the " double-quotes being an essential part of the expression), e.g.,
my $data = "1 2 3 4";
If so, the question becomes "How do I convert a string in the format '1 2 3 4' into a list that I can assign to an array?" The split Perl built-in function can do just this with a string in this format. (Use something like Data::Dumper or Data::Dump to confirm your intermediate results.)
>perl -wMstrict -le "use Data::Dumper; ;; my $data = '1 2 3 4'; my @a = split /\s+/, $data; print Dumper \@a; " $VAR1 = [ '1', '2', '3', '4' ];
Now you have an array from which you can take a reference: my $array_ref = \@a;
This reference could be used in the new() constructor of URI::GoogleChart: data => $array_ref,
or else the result of the referencing operation could be used directly: data => \@a,
or else the array itself could be expanded within an anonymous array constructor: data => [ @a ],
I hope that helps. Update: Oh, and please pay attention to kcott's good advice about effective question-posting and the use of strict and warnings!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: draw picture by google Chart
by HHCHANG (Novice) on Oct 27, 2013 at 06:58 UTC |