Reputation: 165
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.
Upvotes: 2
Views: 4813
Reputation: 387
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+)
Upvotes: 3
Reputation: 1971
How you created your context? It should be
var ctx = document.getElementById("myChart");
Upvotes: 0