I'm trying to use the Perl module Tk::Graph. I have researched this extensivley, but cannot find the right information. The problem is, I need to generate a graph from a two dimensional hash, but all the tutorial and documentation that I read about the module is all showing examples of static graphs, where you put static values in for the data.
This is my code, but it will only generate a one bar graph. It remembers the last value within the loop and only outputs that.
sub reportg{
my( $userjobcount_ref, $userjobcpu_ref, $queuejobsystem_ref, $userjobt
+ime_ref, $queue_cpu_summary_ref, $total_ref, $count) = @_;
my( $total, $avg, $month_or_day,$user, $queue, $system_cpu);
$MW = MainWindow->new;
foreach $month_or_day (sort keys %{$queue_cpu_summary_ref}) {
foreach $queue (sort keys %{$queue_cpu_summary_ref->{$month_or_day}})
{
$usage=sprintf ("%.3f", $$queue_cpu_summary_ref{$month_or_day}{$queue}
+ / $total * 100);
$data = {
$queue => $usage
};
$ca = $MW->Graph(
-type => 'BARS',
-ylabel => 'percentage',
-xlabel => 'queue',
)->pack(
-expand => 1,
-fill => 'both',
);
$ca->configure(-variable => $data); # bind to data
All I get is the last value and key from the hash. Please help it's driving me insane.
2006-09-27 Retitled by planetscape, as per Monastery guidelines: one-word (or module-only) titles hinder site navigation
( keep:0 edit:27 reap:0 )
Original title: 'Tk:: Graph'
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.