[Chartjs]-Chart.js displaying time data

2đź‘Ť

âś…

Your main issue is that moment.js script tag should be placed early in the “script” tags in your example. It will work in your example if you do (also uncomment the “xaxis” section).

So put script tag above chart.js:

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

`

Here is also an easy way to represent whatever you would like in chart.js and get the data and do whatever you’d like (it will also help find your error):

xAxes: [{
   ticks: {
       callback: function(value) {
          //"HH:mm:ss"
          return moment(value).format("mm:ss");
       }
   }
}],

Leave a comment