I have problems while I insert data series on this function
public function chartAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('FarmacoBundle:Farmaco')->findCantfar();
foreach($entities as $datos)
{
$datos['nombreComercial'];
$datos['existencia'];
}
$series = array(
array("name" => "Serie Name", "data" => $datos['nombreComercial'], $datos['existencia'], "type" => "pie")
);
$ob = new Highchart();
$ob->chart->renderTo('piechart');
$ob->title->text('Chart Title');
$ob->series($series);
return $this->render('FarmacoBundle:Default:chart.html.twig', array(
'chart' => $ob
));
}
Repository:
public function findCantfar()
{
$em = $this->getEntityManager();
$query = $em->createQuery('
SELECT f.nombreComercial, f.existencia
FROM FarmacoBundle:Farmaco f
');
$query->setMaxResults(4);
return $query->getResult();
}
thereby it's the result
$(function () { var piechart = new Highcharts.Chart({ chart: {"renderTo":"piechart"}, series: [{"name":"Serie Name","data":"Atamel","0":"115","type":"pie"}], title: {"text":"Chart Title"} }); });
Obviously, Data values are incorrect
How would pass correctly this data ?
regards