1
I’m trying to use phplot to plot a graph within an application made in Zend framework, but it results in error. It is easy to plot with phplot, I am 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 it is returning the following error:
Fatal error: DrawGraph(): No image resource allocated
Could put the part of the code that makes the Plot?
– Felipe Avelar
Here is one of the code I made, as I tried several ways to adapt within the Zend Framework. https://ghostbin.com/paste/tdbah
– Matheus