[Chartjs]-How do I correctly include Moment.js and Chart.js with RequireJS when I want to create charts with time scales?

2๐Ÿ‘

โœ…

Iโ€™ve got the solution at https://github.com/chartjs/Chart.js/issues/4987.

requirejs.config({
  paths: {
    'moment': '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment',
    'chartjs': '//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart'
  }
})

define('moment-adapter', ['moment'], function(moment) {
  window.moment = moment;
  return moment;
})

require(['moment-adapter', 'chartjs'], function(moment, Chart) {
   ...
})

Leave a comment