Hi wishartz,

Please provide a more complete code example.  The subroutine you gave doesn't contain a closing brace "}", nor does it contain the closing brace for either of your foreach statements.

Since the problem you're having appears to be related to how much of the data is formatted for use by the Tk::Graph object, knowing the code to the end of the loops is fairly important.  You should also strongly consider reformatting your indentation to give visual clues about which code belongs in which block; without which your code is pretty difficult to follow.

I will take a guess, though, and assume that the loops both terminate past after the code you showed.  According to the CPAN documentation for Tk::Graph, an example of its usage is:

my $data = { Sleep => 51, Work => 135, Access => 124, mySQL => 5 }; my $ca = $mw->Graph( -type => 'BARS', )->pack( -expand => 1, -fill => 'both', ); $ca->configure(-variable => $data); # bind to data # or ... $ca->set($data); # set data

However, you appear to be calling Tk::Graph multiple times within your foreach loops, and each time assigning only a single pair of data (which I've reformatted here to make immensely more readable):

$data = { $queue => $usage }; $ca = $MW->Graph(-type => 'BARS', -ylabel => 'percentage', -xlabel + => 'queue'); $ca->pack(-expand => 1, -fill => 'both');

It would appear that a partial fix to your problem might involve moving the construction of the Tk::Graph object outside of the inner loop, and within the loop changing the assignment of $data to:

$data->{$queue} = $usage;

so as not to overwrite its previous key/value pairs.

If this doesn't get you past the problem, please consider submitting the entire subroutine.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: Using Tk::Graph to graph two-dimensional data by liverpole
in thread Using Tk::Graph to graph two-dimensional data by wishartz

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.