question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'length' of undefined

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
etimbergcommented, Apr 22, 2016

@paulcanning if you have any ideas on how to improve the docs, I’d be happy to discuss them on our Slack channel

1reaction
etimbergcommented, Apr 21, 2016

@paulcanning preview of new documentation is at http://alpha.chartjs.org/docs/ We will update the main site this sunday.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found