[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-general
Subject:    Re: [PEAR] About Image_Graph Packge
From:       "Daniel O'Connor" <daniel.oconnor () gmail ! com>
Date:       2009-01-25 9:48:27
Message-ID: 106cc1200901250136n25e2105ay946f60908ae3613b () mail ! gmail ! com
[Download RAW message or body]


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();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic