]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix a race condition in the resize listener & use the correct merged config object...
authorEvert Timberg <evert.timberg@gmail.com>
Mon, 12 Oct 2015 13:16:49 +0000 (09:16 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Mon, 12 Oct 2015 13:16:49 +0000 (09:16 -0400)
src/core/core.js

index d930c024fd0f4017991a8a75be38a2701e11395a..039f344199dfd76bc46763a8385bf652e1f3f499 100755 (executable)
                Chart.helpers.retinaScale(this);
 
                // Always bind this so that if the responsive state changes we still work
+               if (config) {
+                       this.controller = new Chart.Controller(this);
+               }
+
                var _this = this;
                Chart.helpers.addResizeListener(context.canvas.parentNode, function() {
-                       if (config.options.responsive) {
+                       if (_this.controller && _this.controller.config.options.responsive) {
                                _this.controller.resize();
                        }
                });
 
-               if (config) {
-                       this.controller = new Chart.Controller(this);
-                       return this.controller;
-               }
-
-               return this;
+               return this.controller ? this.controller : this;
 
        };