[Chartjs]-Chartjs displays numbers not time

29πŸ‘

It turns out, the solution entails version controls (here is what I used):

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>

16πŸ‘

I had this same issue and attempted Kevin’s solution, but it did not work. I found that it was necessary to place the moment script before the chartjs script and regardless of the versions I used, that solved the problem for me.

8πŸ‘

You have to use the bundle version of Chartjs that already include Moment.js

    <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.bundle.js"></script>

1πŸ‘

If you are using npm

npm install moment chartjs-adapter-moment --save-dev

in your files

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

https://github.com/chartjs/chartjs-adapter-moment

0πŸ‘

I had the same error while trying to use chartkick gem for rails.
And the solution was to install moment.js (npm install moment --save) and put

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script> 

in the application.html.erb

Leave a comment