]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Don't try to use undefined Scale constructors 1878/head
authorEvert Timberg <evert.timberg@gmail.com>
Sat, 9 Jan 2016 16:55:44 +0000 (11:55 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Sat, 9 Jan 2016 16:55:44 +0000 (11:55 -0500)
src/core/core.controller.js

index ea58c3ef782a16a941449aca8a1d32c33046730f..c741359c374ed85604d13a63b0d17f4fe1dafed1 100644 (file)
                                if (this.options.scales.xAxes && this.options.scales.xAxes.length) {
                                        helpers.each(this.options.scales.xAxes, function(xAxisOptions, index) {
                                                var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type);
-                                               var scale = new ScaleClass({
-                                                       ctx: this.chart.ctx,
-                                                       options: xAxisOptions,
-                                                       chart: this,
-                                                       id: xAxisOptions.id,
-                                               });
-
-                                               this.scales[scale.id] = scale;
+                                               if (ScaleClass) {
+                                                       var scale = new ScaleClass({
+                                                               ctx: this.chart.ctx,
+                                                               options: xAxisOptions,
+                                                               chart: this,
+                                                               id: xAxisOptions.id,
+                                                       });
+
+                                                       this.scales[scale.id] = scale;
+                                               }
                                        }, this);
                                }
 
                                        // Build the y axes
                                        helpers.each(this.options.scales.yAxes, function(yAxisOptions, index) {
                                                var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type);
-                                               var scale = new ScaleClass({
-                                                       ctx: this.chart.ctx,
-                                                       options: yAxisOptions,
-                                                       chart: this,
-                                                       id: yAxisOptions.id,
-                                               });
-
-                                               this.scales[scale.id] = scale;
+                                               if (ScaleClass) {
+                                                       var scale = new ScaleClass({
+                                                               ctx: this.chart.ctx,
+                                                               options: yAxisOptions,
+                                                               chart: this,
+                                                               id: yAxisOptions.id,
+                                                       });
+
+                                                       this.scales[scale.id] = scale;
+                                               }
                                        }, this);
                                }
                        }
                        if (this.options.scale) {
                                // Build radial axes
                                var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type);
-                               var scale = new ScaleClass({
-                                       ctx: this.chart.ctx,
-                                       options: this.options.scale,
-                                       chart: this,
-                               });
+                               if (ScaleClass) {
+                                       var scale = new ScaleClass({
+                                               ctx: this.chart.ctx,
+                                               options: this.options.scale,
+                                               chart: this,
+                                       });
 
-                               this.scale = scale;
+                                       this.scale = scale;
 
-                               this.scales.radialScale = scale;
+                                       this.scales.radialScale = scale;
+                               }
                        }
 
                        Chart.scaleService.addScalesToLayout(this);