I just installed the Highcharts Bundle package on Symfony 2.7, but I'm already running into a problem trying to reproduce the "Usage Example" from the documentation (cf https://github.com/marcaube/ObHighchartsBundle/blob/master/Resources/doc/usage. md )
Here is my code:
controller
public function homepageAction()
{
$user = $this->getUser();
$securityContext = $this->get('security.context');
$authorization = $securityContext->isGranted('ROLE_REGISTERED_USER');
if ($authorization) {
$ob = new Highchart();
$ob->chart->renderTo('piechart');
$ob->title->text('Browser market shares at a specific website in 2010');
$ob->plotOptions->pie(array(
'allowPointSelect' => true,
'cursor' => 'pointer',
'dataLabels' => array('enabled' => false),
'showInLegend' => true
));
$data = array(
array('Firefox', 45.0),
array('IE', 26.8),
array('Chrome', 12.8),
array('Safari', 8.5),
array('Opera', 6.2),
array('Others', 0.7),
);
$ob->series(array(array('type' => 'pie', 'name' => 'Browser share', 'data' => $data)));
return $this->render('MVPBundle:User:homepage.html.twig', array(
'user' => $user,
'chart' => $ob,
));
} else {
$url = $this->generateUrl('user_displayCompanyCreationForm');
return $this->redirect($url);
}
}
View
<script src='{{ asset('bundles/mvp/js/jquery-2.1.4.js') }}' type="text/javascript"></script>
<script src='{{ asset('bundles/mvp/js/highcharts.js') }}' type="text/javascript"></script>
<script src='{{ asset('bundles/mvp/js/exporting.js') }}' type="text/javascript"></script>
<script type="text/javascript">
{{ chart(chart) }}
</script>
<div id="piechart" style="min-width: 400px; height: 400px; margin: 0 auto"> </div>
After some research, I realized that this could be related to importing JS files, so I made sure that the file paths were ok and that Jquery was imported into JS Highcharts files, so I really don't see where the problem arises .. . :(
I would be grateful for any help! :)
Greetings
source
share