]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Instead of showing a warning on load, throw an error on create if moment is not defined. 2145/head
authoretimberg <evert.timberg@gmail.com>
Wed, 16 Mar 2016 23:59:20 +0000 (19:59 -0400)
committeretimberg <evert.timberg@gmail.com>
Wed, 16 Mar 2016 23:59:20 +0000 (19:59 -0400)
src/scales/scale.time.js

index 66bd891d32ce3a37901a04d18e95081c967f38ae..7e5b7c387597e542dbd844fab949210e2027f6d3 100644 (file)
@@ -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];
                },