mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Merge pull request #2145 from nnnick/fix/2110
Instead of showing a warning on load, throw an error on create if moment is not defined.
This commit is contained in:
commit
67bd2dae6d
@ -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];
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user