The last post has pretty much laid out how I use GD::Graph. Here is an example to look at from something I use. The data I collect is on 5 minute intervals, but the graph can be from a day to several days wide. On a 600x480 graph, if I get more than 24 time values it looks very cluttered. You will want to use x_label_skip for this and x_labels_vertical to stand them on end. I hope it helps. One other thing to consider is using RRDTool. If your graphing app is going 7x24 it can collect your data, age off your data and then produce a graph for you. I use it all the time for just this type of thing. It should install fine on the machine you are using GD::Graph on. It uses all the same stuff. If you would like to see a couple of examples of putting in data and generating a graph I'd be happy to pass on a couple.
# here is where we put a varying amount of timestamps across the graph + depending on how much time is involved. # if this isn't done, you can either see a graph with 2 timestamps or +with so many they are not legible. if ($elapsed_time > 604800){ $x_label_skip = 216; } elsif ($elapsed_time > 172800){ $x_label_skip = 36; } elsif ($elapsed_time > 86400){ $x_label_skip = 24; } elsif ($elapsed_time > 43200){ $x_label_skip = 12; } elsif ($elapsed_time > 3600){ $x_label_skip = 6; } else { $x_label_skip = 1; } foreach $entry (@timeline){ + # build an array of timestamps of date year $date = &SYSTIME($entry); push @dateline, $date; + # the epoch time is converted to a string and saved in a list } $poop = 'CDR data from '.$startdate.' - '.$enddate; + # a fancy title for our graph @data = (\@dateline, \@callAgent_A, \@callAgent_B); + # this is an array of arrays. The first one is the X axis + # which is the time, the others are the Y axis my $query = new CGI; + # start a new cgi object print $query->header(-type => 'image/png'); + # output a content type header for a png file my $data = GD::Graph::Data->new() or die GD::Graph::Data->error; $data->copy_from(\@data); + # this tells the graph to get the data from the data array my $my_graph = new GD::Graph::area(600,480); + # and this says what type (area) and it's size $my_graph->set( + # and set up all the particulars... r_margin => 1, x_label => 'Time', y_label => 'Hourly Attempts', title => $poop, y_min_value => 0, y_tick_number => 8, y_label_skip => 1, x_ticks => 1, x_label_skip => $x_label_skip, x_labels_vertical => 1, x_label_position => 1/2, cumulate => 1, transparent => 1, )or warn $my_graph->error; open (IMG, ">-") or die; + # open up an output file to STDOUT binmode IMG; $my_graph->set( dclrs => [ qw(lgreen lblue) ] ); + # here is the colors in the graph $my_graph->set_legend("Call Agent A","Call Agent B" ); + # and the legend text $my_graph->set_title_font(GD::Font->Giant); print IMG $my_graph->plot($data)->png(); + # and this plots the image out to a png format close IMG;

In reply to Re: Help with GD::Graph by odha57
in thread Help with GD::Graph by jeiku

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.