Giter VIP home page Giter VIP logo

backbone.googlechart's People

Contributors

eranb avatar markcipolla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backbone.googlechart's Issues

Events do not trigger if chart is changed

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);
     };

Issue with event binding

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.