From 8c68f78ec397d1826bb53e58dc204cde10666a99 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 9 Jan 2016 11:55:44 -0500 Subject: [PATCH] Don't try to use undefined Scale constructors --- src/core/core.controller.js | 52 +++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index ea58c3ef7..c741359c3 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -130,14 +130,16 @@ 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); } @@ -145,29 +147,33 @@ // 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); -- 2.47.2