Error trying to generate PHPlot chart in Zend framework

1

I'm trying to use the phplot to plot a graph inside an application made in Zend framework, but it results in an error. It's easy to plot with phplot, I'm using the following code:

// view helper que desenha o grafico
// a helper ja ta configurada no module.config
// ShowGraph.php

<?php

namespace Admin\View\Helper;

use Zend\Phplot\PHPlot;
use Zend\View\Helper\AbstractHelper;

class ShowGraph extends AbstractHelper
{
    public function __invoke($data)
    {

       $plot = new PHPlot(500 , 350); 
       $title = "Consulta de carros";
       $plot->SetTitle($title);
       $plot->SetPlotType("bars");
       $plot->SetDataType("text-data");
       $plot->SetDataValues($data);
       $plot->SetXTickPos('none');
       $plot->SetXLabel("Fonte: GTI Submit");
       $plot->SetXLabelFontSize(2);
       $plot->SetAxisFontSize(2);

       $plot->SetDataValueLabelColor('red');
       $plot->SetYDataLabelPos('plotin');
       return $plot->DrawGraph();
    }
}

?>

// Chamo aqui no index a helper passando array $data
// index.phtml

<img src="<?php echo $this->showGraph($data); ?>" />

However, you are returning the following error:

Fatal error: DrawGraph(): No image resource allocated
    
asked by anonymous 14.04.2015 / 02:19

0 answers