Re: About Image_Graph Packge

From: Date: Sun, 25 Jan 2009 09:36:27 +0000
Subject: Re: About Image_Graph Packge
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-29641@lists.php.net to get a copy of this message
On Sun, Jan 25, 2009 at 6:00 PM, Christian Weiske <cweiske@cweiske.de>wrote: > Hello Ji, > > > > I am trying to generate a graph on a webpage with image_graph. In > > order to make it more dynamic, I am also trying to add input fields > > for the users to choose the minimum range and the maximum range for > > the domain of the graph. I tried "echo"ing the <input> html right > > after calling done() function of the image_graph, but it keeps > > crapping out displays the following error. > > > > *Warning*: Cannot modify header information - headers already sent by > > (output started at /var/www/cmp/index.php:17) in * > > /usr/share/php/Image/Canvas.php* on line *644* > > Image_Graph's done() method directly writes the *image* out to the > browser. It does not generate HTML. So if you want to display both HTML > *and* and image, you have to have separate files, or save the graph in > a temp directory and link it from your HTML page. > A good approach, like the one taken by google's chart api ( http://code.google.com/apis/chart/), is to build a quick graph serving page. # Rendering code: require_once 'Net/URL.php'; function make_graph_url($data) { $url = new Net_URL('graph.php'); $url->querystring['data'] = $data; $url->querystring['type'] = 'pie'; return $url->getURL(); // "graph.php?type=pie&data[Cats]=1&data[Fish]=2"; } # HTML / Presentation bit <img src="<?php print make_graph_url($data); ?>" alt="Graph of Cats and Fish" /> #Graph.php require_once 'Image/Graph.php'; $graph = new Image_Graph(); // read in $_GET and construct your graph $graph->done();

« previous php.pear.general (#29641) next »