mmfs has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I have a hash:
$hash{$x_label}{$y_data}{$uri}with at least 5 different $uri
and I have different x_label and y_data for each uri (x_label is timestamp "%H:%i" and y_data is clicks per minute), that I need to feed GD::Graph @data with.
The problem is that NO uri have the same number of data points and I want to display CPM over TIMESTAMP for each URI, along with the x_label TIMELINE.
The following code:
foreach my $x_label (sort keys %hash_data){ foreach my $uri (keys %{$hash_data{$x_label}}){ print "x: $x_label - value: $hash_data{$x_label}{$uri} + ($uri)\n"; } }
Produces this output:
x: 08:57 - value: 178 (http://some.url.com/2011/07/22/link.jhtm) x: 09:02 - value: 399 (http://some.url.com/2011/07/22/link.jhtm) x: 09:07 - value: 375 (http://some.url.com/2011/07/22/link.jhtm) x: 09:07 - value: 371 (http://other.url.com/link.jhtm) x: 09:12 - value: 358 (http://some.url.com/2011/07/22/link.jhtm) x: 09:12 - value: 35 (http://other.url.com/2011/07/22/link.jhtm) x: 09:17 - value: 373 (http://other.url.com/link.jhtm) x: 09:22 - value: 369 (http://other.url.com/link.jhtm) x: 09:22 - value: 848 (http://another.url.com/permalink) x: 09:22 - value: 789 (http://some.url.com/2011/07/22/link.jthm)
The question is, how do I generate arrays with the same size, for each url, to feed GD::Graph with a proper @data?
I'm trying with multidimensional arrays, but still could not figure out how to code to solve that problem, any thoughts?
thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: creating vectors from hash (GD::Graph) data arrays
by Don Coyote (Hermit) on Aug 05, 2011 at 07:48 UTC |