<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">#!/usr/bin/perl<br><br>use strict;<br>use GD::Graph::area;<br>#use GD::Graph::lines;<br>use Carp;<br>use Time::Local;<br><br>umask 0222;<br><br>#<br># set dimensions for graphics<br>#<br>our ($x,$y) =(500, 210);<br><br><br>open CONFIG, $configfile<br> or die "can't open $configfile: $!";<br><br>our %LOCATION;<br>our %TTY;<br>while (<CONFIG>) {<br> if (/^(\d) (\S+) (\S.*)/) {<br> $LOCATION{$1} = $2;<br> $TTY{$1} = $3;<br> }<br>}<br><br><br><br>my
(@ttyi,@ttyt,@both,@label);<br># $ttyi[$x] = $y; and so on<br># $both[] = sum of tty's on the device, there's always two on each device<br><br><br><br>my @data;<br>my @legend;<br>my @colors;<br><br>if ($TTY{$switch} =~ /ttyt/) {<br> @data = (<br> [ @label ],<br> [ @both ],<br> [ @ttyt ],<br> );<br> @legend = (<br>
'ttyi',<br> 'ttyt',<br> );<br> @colors = (<br> 'red',<br> 'blue',<br> 'cyan',<br> );<br>}<br>else {<br> die "cannot determine proper TTYs";<br>}<br><br><br>$graph = GD::Graph::area->new($x,$y);<br><br><br><br>$graph->set(<br><br><br># x_label => $dateLabel,<br>
x_label => "$title $dateLabel $weekday[$wday]",<br> #x_label => '',<br> x_label_skip => 6 * 3,<br> x_tick_offset => 6 * 3,<br># x_all_ticks => 1,<br><br># two_axes => 1,<br><br> y_label => 'completions / 10 minutes',<br> y_min_value => 0,<br> y_max_value =>
$speed,<br> y_tick_number => $speed/20,<br> y_label_skip => 2,<br><br><br>) or die $graph->error;<br><br>$graph->set( dclrs => [ @colors ] );<br>$graph->set_legend(@legend);<br>$graph->set(<br> legend_placement => 'RT',<br>);<br><br>my $gd = $graph->plot(\@data) or die $graph->error;<br><br><br>open (IMG, '>', $png) or die "can't open '$png': $!";<br>binmode IMG;<br>print IMG $gd->png;<br>close IMG;<br><br>exit;<br><br><br><br><br>--- On <b>Mon, 8/25/08, Mark Fowle <i><mfowle@navicominc.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: Mark Fowle <mfowle@navicominc.com><br>Subject: Re: [tpm] GD::Graph question<br>To: "Madison
Kelly" <linux@alteeve.com><br>Cc: "tpm" <tpm@to.pm.org><br>Received: Monday, August 25, 2008, 8:33 PM<br><br><pre>If SVG is OK for you (client browser support wise)<br>I'd go one of two routes:<br>1. draw a SVG graph with the first dataset and a second graph with<br>almost everything 0% opaque so only the line shows up.<br><br>2. get into SVG Graph and change the code so y scale can be a scalar or<br>an array. Then adjust the scaling code to use the array element<br>corresponding to the dataset.<br><br><br><br>Idea 2 is probably implementable in GD Graph.<br><br>Mark Fowle<br><br><br>-----Original Message-----<br>From: toronto-pm-bounces+mfowle=navicominc.com@pm.org<br>[mailto:toronto-pm-bounces+mfowle=navicominc.com@pm.org] On Behalf Of<br>Madison Kelly<br>Sent: Monday, August 25, 2008 4:26 PM<br>To: Scott Elcomb<br>Cc: tpm<br>Subject: Re: [tpm] GD::Graph question<br><br>Scott Elcomb wrote:<br>> On Sun, Aug 24, 2008 at 7:47 PM, Alex
Beamish <talexb@gmail.com><br>wrote:<br>>> My first Perl gig ten years ago was doing graphs, and I used Gnuplot<br>>> quite successfully to draw graphs-- it's a very flexible package.<br>> <br>> Hmm. My first gig involved writing wrappers around GD::Graph. Since<br>> it was "my first gig" the code in my ... um... uh... library<br>"SAL"<br>> definitely reflects that. One day I might even get around to<br>> modernizing it and making it useful.<br>> <br>> Unfortunately (fortunately?) I never had to deal with this particular<br>> problem. Madison, if you find a solution could I ask that you post it<br>> up for us?<br>> <br>> Many thanks.<br>> - Scott.<br><br>At this point, I've moved on from GD::Graph and am playing with <br>SVG::TT::Graph. I'm having mixed luck; It seems like a much more <br>flexible solution and I am getting cleaner graphs, but I have not yet <br>been enable to figure out to create
a dual Y-axis graph, assuming it is <br>possible at all.<br><br>Once I figure something out I will indeed post it to the list "for <br>posterity". :)<br><br>Madi<br>_______________________________________________<br>toronto-pm mailing list<br>toronto-pm@pm.org<br>http://mail.pm.org/mailman/listinfo/toronto-pm<br>_______________________________________________<br>toronto-pm mailing list<br>toronto-pm@pm.org<br>http://mail.pm.org/mailman/listinfo/toronto-pm<br></pre></blockquote></td></tr></table>