I am trying to declare a new chart using chart.js , but the chart is not rendering.
I originally tried declaring it using:
new Chart(ctx).Pie(data);
However, that code gave me the following error:
Uncaught TypeError: (intermediate value).Pie is not a function
I tried changing the code to:
new Chart(ctx , {
type: "pie",
data: data,
});
This caused the error to disappear, yet the chart still doesn't render.
I've tried using different browsers and the same issue still occurs.
JSFiddle link: https://jsfiddle.net/pv77779y/
Any help with getting the chart to render would be massively appreciated.
I was facing a similar issue wherein the chart.js documentation was not helpful. Then I noticed that the chart.min.js version should be the latest one. This day we use 2.5+ and the documentation is for that version.
So try replacing the file, and reloading your page (conforming to documents of chart.min.js 2.5+)
How you created your context? It should be
var ctx = document.getElementById("myChart");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.