我想用ObHighchartsBundle创建一个条形图(下面的图片),但我无法做到这一点,图表呈现为空!问题出在图表栏的类型中 甚至可以使用ObHighchartsBundle
我的代码:
chartingController .php:
public function productionEst($date,$liste1,$liste2,$liste3)
{
$ob = new Highchart();
$dates = $date;
$production = array(
$liste1,
$liste2,
$liste3
);
$ob->chart->type('bar');
$ob->chart->renderTo('container'); // The #id of the div where to render the chart
$ob->plotOptions->bar(
array(
'dataLabels' => array(
'enabled' => true
)
)
);
$ob->title->text('Production);
$ob->xAxis->categories($dates );
$ob->xAxis->title(array('text' => "Horizontal axis title"));
$ob->yAxis->title(array('text' => "Vertical axis title"));
$ob->legend->legend(
array(
'layout' => 'vertical',
'align'=> 'right',
'verticalAlign' =>'top',
'floating'=> true,
'borderWidth' =>1,
'shadow' =>true
)
);
$ob->series($production);
return $ob;
}
index.twig:
<div id="container" style="min-width: 200px; height: 600px; margin: 0 auto"></div>
<script type="text/javascript">
{{ chart(container) }}
</script>