kontera-technologies / backbone.googlechart Goto Github PK
View Code? Open in Web Editor NEWGoogle Charts support for your Backbone app
License: MIT License
Google Charts support for your Backbone app
License: MIT License
Hello,
Thanks for the library, I was trying to use the event binding using
chart.on("select",function(chartObject) {
alert("Someone clicked on column " + chartObject.getSelection()[0].column);
});
but I am getting following errors:
Uncaught TypeError: Cannot read property 'events' of undefined GoogleChart.js:223
Backbone.GoogleChart.GoogleChart._addGoogleListener GoogleChart.js:223
__bind GoogleChart.js:4
Backbone.GoogleChart.GoogleChart.bind GoogleChart.js:180
app.PromotionDetailsView.Backbone.View.extend.progressChart details.js:45
triggerEvents backbone.js:98
Backbone.Events.trigger backbone.js:187
_.extend.set backbone.js:350
_.extend.fetch.options.success backbone.js:419
Backbone.sync.options.success backbone.js:1430
jQuery.Callbacks.fire jquery-1.9.0.js:1017
jQuery.Callbacks.self.fireWith jquery-1.9.0.js:1127
done jquery-1.9.0.js:8021
jQuery.ajaxTransport.send.callback
Essentially in this part of the code
GoogleChart.prototype._addGoogleListener = function(event) {
var _this = this;
return this.google.events.addListener(this.wrapper, event, function() {
return _this.trigger(event, _this.wrapper.getChart());
});
};
this does not have google as the property.
Any help is appreciated.
I have a Backend view containing:
OpenDisclosure.Views.PaymentCategory = Backbone.View.extend({
.... other code skiped .....
pieChart = new Backbone.GoogleChart({
chartType: 'PieChart',
options: {
// 'title':'Total Contributions by Category',
// 'titleTextStyle':{'fontSize':30, 'fontName':'Crete Round', 'color':'#555555'},
'backgroundColor': '#E9E9E9',
'chartArea': {
'width': 300
},
'width': 300,
'height': 250,
'sliceVisibilityThreshold': 0
},
dataTable: data,
});
pieChart.render();
// Clicking on the chart loads the details
pieChart.on('select', this.displayDetails);
The first time I instantiate an instance of this view I get select events. When I instantiate any subsequent instances then the select event does not trigger. The following change fixes the problem. I don't know enough (or really anything) about the library to know why or if this is not a good idea.
--- a/assets/js/vendor/GoogleChart.js
+++ b/assets/js/vendor/GoogleChart.js
@@ -179,7 +179,8 @@
GoogleChart.prototype.bind = function(event, callback) {
var _base;
- (_base = this._listers)[event] || (_base[event] = this._addGoogleListener(even
+ _base = this._listers;
+ _base[event] = this._addGoogleListener(event);
return GoogleChart.__super__.bind.call(this, event, callback);
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.