我正在使用来自 PEAR 的名为 Image_Graph 的 PHP 图形库来绘制由条形表示的数据点。当有多个数据点时,图表看起来很好,但是当只有一个数据点时,它看起来像这样:
http://img594.imageshack.us/img594/2944/screenshot20100715at528s.png
有没有其他人在使用 PEAR 的 Image_Graph 之前遇到过这个问题?有谁知道修复?我尝试使用最新版本的 Image_Graph 以及来自 SVN 的副本。
这是我的图形代码:
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 )));
}
我认为这一定是 Image_Graph 的一个错误,但我不确定它可能在哪里。
谢谢你的帮助!