[Chartjs]-Sequence of loading JavaScript <script> files

1👍

You need to include Moment.js before Chart.js.

The Chart.js documentation could do a better job of highlighting this, but it is explained on the installation page:

The stand-alone build includes Chart.js as well as the color parsing library. If this version is used, you are required to include Moment.js before Chart.js for the functionality of the time axis.

If you can’t change the load order then perhaps use the bundled build of Chart.js instead (and don’t load Moment.js separately):

The bundled build includes Moment.js in a single file. You should use this version if you require time axes and want to include a single file. You should not use this build if your application already included Moment.js. Otherwise, Moment.js will be included twice which results in increasing page load time and possible version compatibility issues. The Moment.js version in the bundled build is private to Chart.js so if you want to use Moment.js yourself, it’s better to use Chart.js (non bundled) and import Moment.js manually.

Leave a comment