From: etimberg Date: Wed, 16 Mar 2016 23:59:20 +0000 (-0400) Subject: Instead of showing a warning on load, throw an error on create if moment is not defined. X-Git-Tag: v2.0.0~14^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2145%2Fhead;p=thirdparty%2FChart.js.git Instead of showing a warning on load, throw an error on create if moment is not defined. --- diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 66bd891d3..7e5b7c387 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -7,12 +7,6 @@ moment = typeof(moment) === 'function' ? moment : window.moment; module.exports = function(Chart) { var helpers = Chart.helpers; - - if (!moment) { - console.warn('Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at http://momentjs.com/'); - return; - } - var time = { units: [{ name: 'millisecond', @@ -73,6 +67,13 @@ module.exports = function(Chart) { }; var TimeScale = Chart.Scale.extend({ + initialize: function() { + if (!moment) { + throw new Error('Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com'); + } + + Chart.Scale.prototype.initialize.call(this); + }, getLabelMoment: function(datasetIndex, index) { return this.labelMoments[datasetIndex][index]; },