I'm using a PHP graphing library from PEAR called Image_Graph to graph points of data in represented by bars. The graphs look fine when there's more than one datapoint, but when there's only one data point it looks like this:
http://img594.imageshack.us/img594/2944/screenshot20100715at528s.png
Has anyone else experienced this problem with PEAR's Image_Graph before? Does anyone know a fix? I have tried using the latest version of Image_Graph as well as a copy from SVN.
Here is my graphing code:
public function drawGraph() {
$canvas =& Image_Canvas::factory('png', array('width' => 775, 'height' => 410, 'antialias' => true));
$graph =& Image_Graph::factory('graph', $canvas);
$font =& $graph->addNew('ttf_font', 'lib/fonts/Helvetica_Neue.ttf');
$font->setSize(12);
$graph->setFont($font);
$plotarea =& $graph->addNew('plotarea');
$dataset =& Image_Graph::factory('dataset');
foreach ($this->getResults() as $res) {
$dataset->addPoint($res['name'], $res['value']);
}
$plot =& $plotarea->addNew('bar', &$dataset);
$axisTitle = $this->_resultType->getName() . " (" . $this->_resultType->getUnits() . ")";
$axisY =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$axisY->setTitle($axisTitle, 'vertical');
$filename = $this->_getFilename();
return ($graph->done(array('tohtml' => 'true',
'filename' => GRAPHS_DIR . $filename )));
}
I think this has got to be a bug with Image_Graph, but I'm not sure where it could be.
Thanks for your help!