简体   繁体   中英

Uncaught TypeError: Cannot read property 'arc' of undefined

I am new to D3 and badly stuck in this error Uncaught TypeError: Cannot read property 'arc' of undefined as I am not able to figure out why this error is coming, It doesn't come every time and I have no idea how to reproduce this one.

Using this one code d3.arc().innerRadius(this.prop.innerRadius).outerRadius(this.prop.outerRadius) to plot donut chart.

I have followed this DOC to configure d3 with requireJS

Here are my configuration details:

• Backbone JS (v1.3.3)

• Require JS (v2.3.3)

• D3 v4.4.0 & tried v5.7.0

• Using the donut chart in Cordova android app

• Android version-6.1.0

• Cordova-7.1.2

You are probably trying to access d3 before the file is loaded. That might be why you're not able to reproduce the issue.

Try moving your code inside an onload function?

$(document).ready(function() { 
  d3.arc().innerRadius(this.prop.innerRadius).outerRadius(this.prop.outerRadius)
});

Or window.onload if you don't have jQuery

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM