easiest way to create a graph?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm looking at adding some basic line graphs to a page.  Enabled gd, and
started in on pear::image_graph.  Just wanting to start simple, I created a
new graph, set the background color, and displayed it.  I also added the
header call to set the content for jpeg, but all I get is a bunch of
characters on my screen.

Here's the (excerpted) simple code:

    Header ("Content-type: image/jpeg");

    $defwidth = 300;
    $defheight = 200;
    $mychart = new Image_Graph($defwidth, $defheight);
    // build the chart

I also couldn't figure out what setBackgroundColor expected, Are there any
samples about for this?


Re: easiest way to create a graph?

Quoted text here. Click to load it

I get it.  You need to have the <img...> tag to get an image in the first
place, and can only get the image from the gd library indirectly.  I think
the design is a bit off.  If I'm forced to put the img source in different
script, it makes my database access more complex than necessary, or I can
drop it in a file, which just slows down the script.  Yuck.  I would much
prefer to directly use the imagepng call as the img source (i.e. <img
src=imagepng(resource)> ).

Oh well.  At least I have a nice white box now!


Site Timeline