[Chartjs]-ChartJS not displaying time data using Moment.js

2๐Ÿ‘

I solved it by adding:

import { Chart } from 'chart.js';
import 'chartjs-adapter-moment';

as pointed out by the doc

0๐Ÿ‘

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.

-1๐Ÿ‘

You could try to put the moment.js script above the chart.js. However here is an example of using moment.js that may help you.

https://stackoverflow.com/a/58555196/12176979

Leave a comment