I am currently using backbone.js with GoogleCharts. Instead of loading Google visualizations into your View () rendering method, you can load backbone.js in your script beyond your backlinks.
<script> google.load('visualization', '1', {packages:'linechart'}); ChartView = Backbone.View.extend({ render:function () { this.drawVisualization(); return this; }, drawVisualization:function () { .... chart.draw(data, null, null); } </script>
This may result in another error. I noticed that calling “chart.draw” from rendering (at this point the “el” view is still not part of the DOM, causes Google Charts to throw an error “Your browser does not support charts”.
I would call the drawVisualization function after you are sure that the View 'el' has been inserted into the DOM for an example. on an event in a view (or its model). Say:
<script> google.load('visualization', '1', {packages:'linechart'}); ChartView = Backbone.View.extend({ events:{ this.model.on('change',this.drawVisualization, this); }, render:function () { this.drawVisualization(); return this; }, drawVisualization:function () { .... chart.draw(data, null, null); } </script>
Hope this helps.
source share