Closed L0kidor closed 5 years ago
This example works for me. Did you correctly include the library in your template ?
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
(test with last stable version of Google chart and last version of this bundle)
I did, many other charts works fine. My config :
cmen_google_charts: version: "current" language: "fr"
And the template
`
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
{{ gc_draw(statsAnnuelles, 'div_chart') }}
</script>`
In my controller, i return that :
return $this->render('statistiques/annuelles.html.twig', array("statsAnnuelles" => $pieChart));
Could you inspect the code with your browser and send me the generated Javascript for this chart ?
yep, here it is :
`
`
The console doesn't show any error.
You have format errors for dates "This value is not a valid datetime.".
Here my version :
google.visualization.arrayToDataTable([[{"label":"Date","type":"date"}, {"label":"Attendance","type":"number"}],
[new Date(2012, 2, 13, 00, 00, 00), 37032],
[new Date(2012, 2, 14, 00, 00, 00), 38024],
[new Date(2012, 2, 15, 00, 00, 00), 38024],
[new Date(2012, 2, 16, 00, 00, 00), 38108],
[new Date(2012, 2, 17, 00, 00, 00), 38229],
[new Date(2012, 2, 18, 00, 00, 00), 38177],
[new Date(2012, 2, 19, 00, 00, 00), 38705],
[new Date(2012, 2, 20, 00, 00, 00), 38210],
[new Date(2012, 2, 21, 00, 00, 00), 38029],
[new Date(2012, 2, 22, 00, 00, 00), 38823],
[new Date(2012, 2, 23, 00, 00, 00), 38345],
[new Date(2012, 2, 24, 00, 00, 00), 38436],
[new Date(2012, 2, 25, 00, 00, 00), 38447]], false);
You should check date values passed into method setArrayToDataTable.
Got it !
In the example the dates are passed like that :
[ new DateTime('2012-03-13'), 37032 ],
wich is interprated as Symfony\Component\Validator\Constraints\DateTime.
Adding \
before datetime make it interpreted as php dateTime:
[ new \DateTime('2012-03-13'), 37032 ],
And that works fine.
Thanks for supporting.
:+1:
I, trying to setup a calendar chart. I begin by copying pasting the example provided in the doc but not working. Got the error mentioned in the title. Did I forget any include statement or whatever ?