Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to test the example of the DataTree of D3Js and I just copied and pasted the code in: http://bl.ocks.org/d3noob/8329447 . I saved the TreeData.json in my C drive and changed the d3.json("treeData.json", function(error, treeData) to d3.json("C: reeData.json", function(error, treeData) and I get the error of "Cannot read property '0' of undefined" by looking at the javascript console. But once I hard code the json file into the program it works fine. Can somebody help me with that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
196 views
Welcome To Ask or Share your Answers For Others

1 Answer

The issue is that web pages can't read your C drive you need to put the relative path to your json file in you project.

Easiest way to do this is to treeData.json file in the project folder with your treeData.json


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...