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


In reply to creating vectors from hash (GD::Graph) data arrays by mmfs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.