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 'width' of undefined

See original GitHub issue

With the latest release c3 release (download link from main website) and d3.v3.min.js

Google Chrome 36.0.1985.49 beta

I am surprised this doesn’t work right out of the box. Am I doing something wrong?

<!DOCTYPE html>
<html>
<head>
  <link href="c3.css" rel="stylesheet" type="text/css">

  <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
  <script src="c3.js"></script>

  <script>
    var chart = c3.generate({
     data: {
       columns: [
         ['data1', 30, 200, 100, 400, 150, 250],
         ['data2', 50, 20, 10, 40, 15, 25]
       ]
     }
   });
  </script>
</head>
<body>

  <div class='chart'>
  <div id="chart"></div>
  </div>

</body>
</html>

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
brooksbpcommented, Jun 17, 2014

If I move the JavaScript to the bottom of ‘body’ tag it works. Interesting… Can someone please comment as to why this is necessary before I close this issue? Thanks!

3reactions
sagar232000commented, Mar 11, 2019

try this way to solve problem: use script inside the body tag like this: Capture

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'width' of undefined in JavaScript - Stack ...
Here canvas variable is undefined . You trying to access canvas before settings its value. var canvas=document.getElementById("canvas ...
Read more >
Cannot read property 'width' of undefined (Image Function ...
Uncaught TypeError: Cannot read property 'width' of undefined (Image Function) · Issue #4749 · processing/p5. js · GitHub.
Read more >
Read property 'width' undefined - Processing forum
Hi, I am somewhat of an intro coder for p5.js. Anyways, I am working on some code that changes a drawFunction I made...
Read more >
Issue with "TypeError Cannot read property 'width' of ...
basically the key part of the error message is the "of undefined". that always means that the engine is missing a data object,...
Read more >
Getting error as "Cannot read property 'width' of undefined"
I am trying to draw a solidgauge chart. Above one is a configuration of chart. I am working on angular and already imported...
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