tsvik_t has asked for the wisdom of the Perl Monks concerning the following question:

Hi there, I'm trying to write some graphs on the fly throw a cgi and I can't make it print more then one graph. this is the line I use to print the graphs:
print $q->header("image/png"); binmode STDOUT; print $graph->plot(\@data)->png;
thanks Tsvika.

Edit kudra, 2002-06-23 Changed title

Replies are listed 'Best First'.
Re: GD::graph
by broquaint (Abbot) on Jun 23, 2002 at 14:14 UTC
    Check out this node which asks a simliar question but the problem is essentially the same (which is having multiple content types in one document).
    HTH

    _________
    broquaint

Re: GD::graph
by Beatnik (Parson) on Jun 23, 2002 at 13:56 UTC
    Yes, GD::Graph does single graphs per pop but you can use GDs copy to copy the graph plot onto antoher image and thus combine several plots...

    Greetz
    Beatnik
    ...Perl is like sex: if you're doing it wrong, there's no fun to it.
Re: Multiple GD::graphs in one web page?
by dws (Chancellor) on Jun 23, 2002 at 17:45 UTC
    I'm trying to write some graphs on the fly throw a cgi and I can't make it print more then one graph.

    You can't expect to slam the bits for two different images together and have a browser see the resulting bits as two images. The image formats just don't work that way. You can, as Beatnik suggests above, use GD to construct a (single) larger image out of multiple smaller images.

    An alternative is to invoke your CGI twice from within an HTML wrapper, producing a different graph for each invocation. Unless both graphs involve a complicated derived dataset, I would think that producing one graph per CGI invocation would be simpler.

      I know this is a reallyyyy old post but how would you do that ---> (use GD to construct a (single) larger image out of multiple smaller images)
Re: GD::graph
by Aristotle (Chancellor) on Jun 23, 2002 at 13:45 UTC
    Well, one CGI invokation can only produce exactly one document. What are you actually trying to do? I get the feeling it is something that has to be done in a different way than you think.

    Makeshifts last the longest.

      What I'm trying to do is print two graphs on the same page like a bar graph and a pie graph, one next to the other but the cgi prints only the first graph and ignore the second one.
        You need to pass your CGI a parameter to tell it which graph you want. It obviously can't know which part of the page it's being called for (in fact, it doesn't even know there is a link to it on a page). After all, if you type the CGI's URL in your browser address bar, how would it decide it what to do? Append something like ?type=bar to the URL and read up on CGI's param() function.

        Makeshifts last the longest.