Running TreeData example D3JS

萝らか妹 提交于 2019-12-25 18:39:51

问题


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:\treeData.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?


回答1:


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



来源:https://stackoverflow.com/questions/28615033/running-treedata-example-d3js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!