I have a similar dynamic image up at the Winfield V.F.D. website. Just check the right column for the EMS calls. I called it like an image and it works fine ( it even has support to create graphs from databases YEAH!! ). Here's my suggestion
Take all the code out that isn't in the class out of there and paste it into a new file and call it financegraph.php. I'm going to use drawgraph.php as the name of the file that contains the class. Now, keep the code the way it is, and just call it as an image:
<html><head></head>
<body>
<img src="http://www.domain.com/scripts/financegraph.php">
</body>
</html>
I.e. All of this code:
//Example -- comment this out if you want to use the class on other pages.
header ("Content-type: image/png"); #Line added to ensure image displays correctly in browser
$plot = new plot2D();
$plot->setTitle("John's spending habits");
$plot->setDescription("Days of the week", "Dollars spent");
$plot->setGrid();
$plot->addCategory("Food", 0xCC, 0x00, 0x00);
$plot->addItem("Food", "sun\n12/1", 152);
$plot->addItem("Food", "mon\n12/2", 76);
$plot->addItem("Food", "tues\n12/3", 81);
$plot->addCategory("Candy", 0x00, 0xCC, 0x00);
$plot->addItem("Candy", "sun\n12/1", 51);
$plot->addItem("Candy", "mon\n12/2", 127);
$plot->addItem("Candy", "tues\n12/3", 45);
$plot->printGraph();
$plot->destroy();
will be in finiancegraph.php. This file will be called to create the graph, and it will show as an image in the browser.
~Brett