GD::graph prob

how do you draw mulitple images on a web page using GD::graph
the following is the code for printing the graph so far.

sub print_graph#prints the graph to screen
{

my $q = new CGI;
my ($xarray,$values,$xlabel,$ylabel,$title,$IfNum) = @_;
my @data = ($xarray,$values);
$title = $title.$IfNum;
my $graph = new GD::Graph::lines(500,350);
$graph->set
(
x_label => $xlabel,
y_label => $ylabel,
title => $title,
x_label_skip => 'auto',
y_label_skip => 'auto',
line_width => 1,
y_tick_number => 8,
x_labels_vertical => 1,
x_label_position => 1/2,
transparent => 0,
);

my $gd_image = $graph->plot(@data);
print header(-type => "image/png");
binmode STDOUT;
print $gd_image->png;
}

its called twice to print out the number of packets recieved on each interface in a workstation but it only ever prints out the first one. (the software loop back)

Comments

  • : how do you draw mulitple images on a web page using GD::graph
    : the following is the code for printing the graph so far.
    :
    : sub print_graph#prints the graph to screen
    : {
    :
    : my $q = new CGI;
    : my ($xarray,$values,$xlabel,$ylabel,$title,$IfNum) = @_;
    : my @data = ($xarray,$values);
    : $title = $title.$IfNum;
    : my $graph = new GD::Graph::lines(500,350);
    : $graph->set
    : (
    : x_label => $xlabel,
    : y_label => $ylabel,
    : title => $title,
    : x_label_skip => 'auto',
    : y_label_skip => 'auto',
    : line_width => 1,
    : y_tick_number => 8,
    : x_labels_vertical => 1,
    : x_label_position => 1/2,
    : transparent => 0,
    : );
    :
    : my $gd_image = $graph->plot(@data);
    : print header(-type => "image/png");
    : binmode STDOUT;
    : print $gd_image->png;
    : }
    :
    : its called twice to print out the number of packets recieved on each interface in a workstation but it only ever prints out the first one. (the software loop back)
    :
    You need to generate each image by a seperate call to a script. Think about it in terms of the HTML:-

    image

    image

    And yes, I agree it's ugly that you need 3 script executions, one to generate a page of HTML and another two for the graphs. Of course, you could have the HTML one generate the graph images and save them to disk, then reference them. You'd then need to delete them at a later time. Alternatively, does GD allow you to generate two images and then put them together into one larger canvas so really you have one big image containing the two?

    Hope this helps,

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion