Skip to content Skip to sidebar Skip to footer

ChartJS Not Displaying Time Data Using Moment.js

I am trying to map out a series of data points on a given day by the hour. Not every hour is included in the data set, however I still want to show the time from 0:00 - 23:00 and p

Solution 1:

I solved it by adding:

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

as pointed out by the doc


Solution 2:

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.


Solution 3:

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


Post a Comment for "ChartJS Not Displaying Time Data Using Moment.js"