我正在尝试在我的symfony项目中集成OBHighChartsBundle。我按照https://github.com/marcaube/ObHighchartsBundle上的教程进行了操作。
我的控制器:
public function piechartAction()
{
$data = [
['Microsoft Internet Explorer', 56.33],
['Chrome', 24.03],
['Firefox', 10.38],
['Safari', 4.77],
['Opera', 0.91],
['Proprietary or Undetectable', 0.2]
];
$ob = new Highchart();
$ob->chart->renderTo('container');
$ob->chart->type('pie');
$ob->title->text('My Pie Chart');
$ob->series(array(array("data"=>$data)));
return $this->render('CarteProassurBundle:Default:index.html.twig', [
'mypiechart' => $ob
]);
}
我的观点:
<!-- Load jQuery from Google's CDN if needed -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="//code.highcharts.com/4.1.8/highcharts.js"></script>
<script src="//code.highcharts.com/4.1.8/modules/exporting.js"></script>
<script type="text/javascript">
{{ chart(mypiechart)}}
</script>
<div id="linechart" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
我检查页面时有一个空白页面并出错:
highcharts.js:13 Uncaught Highcharts错误#13:www.highcharts.com/errors/13
有人知道如何解决这个问题吗?
答案 0 :(得分:0)
renderTo
的值应该是div的id(在您的情况下为linechart
(不是container
))。