eyncydious has asked for the wisdom of the Perl Monks concerning the following question:
Here's the deal: I have 22 routers all updating a data repository. I would like to chart a variable number (user selected) of those routers' data. Typical plotting would be something like: From 1200 to 1900, show me all the counters for OID 1.1.1.1.1.1 for interface Fastethernet1/1.
I have the core of that program built but I'm having major issues plotting multiple lines to the same graph from a loop. Here's a terrible example of what I'm trying to gather.
use strict; use Chart::Gnuplot; # Date array my @x = qw( 2007-01-01 2007-01-10 2007-01-24 2007-02-01 2007-02-14 ); my @b = ([1, 2, 3, 4, 5], [6, 7, 8, 9, 10]); my @p; my @n; # Create the chart object my $chart = Chart::Gnuplot->new( output => 'datetime_1.png', xlabel => + 'Date axis', timeaxis => "x", ); # Data set object for my $i ( 1 .. 1) { @n = (); for my $j ( 0 .. $#{$b[$i]}) { print "b[$i][$j] is $b[$i][$j]\n"; push(@n,$b[$i][$j]); } my $plot = Chart::Gnuplot::DataSet->new( xdata => \@x, ydata => \@n, style => 'linespoints', timefmt => '%Y-%m-%d', ); $chart->plot2d($plot); }
The example is full of hackery and not very well built, I fully admit that. I think the issue is the chart object is receiving a new bout of state on each iteration of the loop and isn't incrementing in step with the loop. Short of manually scripting out:
$chart->plot2d($val1) if $val == 1; $chart->plot2d($val1,$val2) if $val == 2; $chart->plot2d($val1,$val2,$val3) if $val == 3; etc...
I'm not sure this is even possible. Appreciate any thoughts or suggestions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Populate 2d Chart Using Chart::Gnuplot from a Loop
by kcott (Archbishop) on May 13, 2013 at 04:51 UTC | |
by Anonymous Monk on May 06, 2015 at 23:33 UTC | |
by goutham (Initiate) on Jun 15, 2015 at 13:54 UTC | |
by goutham (Initiate) on Jun 15, 2015 at 13:55 UTC | |
by kcott (Archbishop) on Jun 16, 2015 at 03:10 UTC |