Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Loading specific columns into arrays

by poj (Priest)
on Aug 16, 2013 at 13:08 UTC ( #1049736=note: print w/ replies, xml ) Need Help??


in reply to Loading specific columns into arrays

I'm guessing this is what you want, a 2 bar graph

#!perl use strict; use warnings; use GD::Graph::bars; my $tb2 = "Date Start Time End Time Egress Sent 08-15-2013 00:22:22 00:22:29 16.53 3.85 08-15-2013 01:22:22 01:22:28 17.05 3.6 08-15-2013 02:22:23 02:22:28 16.79 3.61 08-15-2013 03:22:24 03:23:27 103.89 37.29 08-15-2013 04:22:24 04:22:26 2.1 0.18 08-15-2013 11:22:25 11:25:11 73.72 60.98 08-15-2013 12:22:25 12:27:55 146.65 133.68"; my @records = split /\n/,$tb2; my $header = shift @records; my @graph=([],[],[]); for my $line (@records){ my @f = split /\s+/,$line; print join '|',@f,"\n"; push $graph[0],"$f[0] $f[1]"; push $graph[1],$f[3]; push $graph[2],$f[4]; } my $my_graph = GD::Graph::bars->new(600,450); print STDERR "Processing Graph\n"; $my_graph->set( x_label => 'Timestamp', x_labels_vertical => 1, y_label => 'Data Conveyed/Sent', title => 'Conveyed Vs. Sent', long_ticks => 1, y_max_value => 200, y_tick_number => 8, y_label_skip => 2, bar_spacing => 3, bargroup_spacing => 10, shadow_depth => 4, accent_treshold => 200, transparent => 0, ); $my_graph->set_legend('Conveyed', 'Sent'); my $gd = $my_graph->plot(\@graph); # save graph my $gif = 'file.gif'; open(IMG, '>',$gif) or die "Could not open $gif $!"; binmode IMG; print IMG $gd->gif; close IMG; print "$gif created\n";
poj


Comment on Re: Loading specific columns into arrays
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049736]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2015-07-08 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls