Uncaught TypeError: Cannot read property 'length' of undefined
See original GitHub issueI am getting this error when trying to create a simple pie chart.
My code:
(function($) {
var data = [
{
value: 1,
color: "#F7464A",
highlight: "#FF5A5E",
label: "A"
},
{
value: 2,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "B"
}
];
var ctx = $("#myChart").get(0).getContext("2d");
var myPieChart = new Chart(ctx[0]).Pie(data, {
animateScale: true
});
}(jQuery));
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >Cannot read properties of undefined (reading 'length') - TrackJS
This message indicates that our code expects to have an object with a length property, but that object was not present. length is...
Read more >Typeerror: Cannot Read Property 'length' of Undefined
A typeerror length of undefined can indicate that the actual type of an operand is different from the expected type. This error can...
Read more >[SOLVED] Cannot Read Property 'length' of Undefined in JS
To fix the “cannot read property 'length' of undefined” error, perform an undefined check on the variable before accessing the length property ......
Read more >Uncaught TypeError: Cannot read property 'length' of undefined
The solution is check for null or undefined (to see whether the object exists) and only then iterate. Share.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@paulcanning if you have any ideas on how to improve the docs, I’d be happy to discuss them on our Slack channel
@paulcanning preview of new documentation is at http://alpha.chartjs.org/docs/ We will update the main site this sunday.