运行TreeData示例D3JS [英] Running TreeData example D3JS

查看:103
本文介绍了运行TreeData示例D3JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试测试D3J的DataTree示例,我只是将代码复制并粘贴到: http://bl.ocks.org/d3noob/8329447 .我将TreeData.json保存在C驱动器中,并将d3.json("treeData.json",function(error,treeData)更改为d3.json("C:\ treeData.json",function(error,treeData)和通过查看JavaScript控制台,我收到无法读取未定义的属性'0'的错误".但是,一旦我将json文件硬编码到程序中,它就可以正常工作.有人可以帮助我吗?

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?

推荐答案

问题是网页无法读取您的C驱动器,您需要在项目中放入json文件的相对路径.

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.

最简单的方法是使用treeData.json将项目文件夹中的treeData.json文件

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

这篇关于运行TreeData示例D3JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆