39👍
After revisiting the question, here’s your problem: you are using the wrong version of chart.js
. According to this section, if you want to use an axis that’s time based, you either need to explicitly include moment.js
, or use the bundle version.
Changing the resource in your jsfiddle to https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.bundle.min.js
will show the expected chart. No need to change the code at all.
4👍
If you want to use Chart.js v2.0 then this CDN will work.
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.bundle.min.js
2👍
You have to use the version 2 of chart.js
. If you are using npm, in your package.json
, update chart.js e.g., "chart.js": "^2.1.1",
. In case you use react-chartjs-2, you will still need to make sure that your chart.js version is 2 or bigger.
2👍
Use this : var ctx = document.getElementById("myChart").getContext("2d");
Instead of : var ctx = document.getElementById("myChart");