D3.js starter(noob):如何从bl.ocks.org/mbostock工作中获取D3示例? [英] D3.js starter(noob): How to get a D3 example from bl.ocks.org/mbostock working?

查看:122
本文介绍了D3.js starter(noob):如何从bl.ocks.org/mbostock工作中获取D3示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对JavaScript和D3.js完全陌生.最近几天,我做了一些工作,例如为图表制作适当的json对象,并想知道如何获取该示例特别运行.指向适当链接的任何方向都很好,尽管我希望以任何丢失的标签或我需要注意的任何细节的形式得到答案.

I'm completely new to JavaScript and D3.js. I have done some work in recent days, like making appropriate json object for the graph, and wanted to know how to get this example running in particular. Any direction to appropriate links would be great, though I would prefer to get an answer in the form of any missing tags or any details I need to take care of.

注意:我必须在本地运行它,而不是在服务器-客户端模型上运行.

Note: I have to run it locally, not on server-client model.

更新:我已经做了很多次,比尔回答了,但没有成功.因此,我再次尝试,然后在浏览器中打开控制台以检查是否有任何错误.得到了:

Update: I have done it a lot of times what Bill answered, it didn't work. So I tried again and I opened the console in browser to check for any errors. Got this:

Failed to load resource:       file://d3js.org/d3.v3.min.js

net::ERR_FILE_NOT_FOUND

index.html:23 Uncaught ReferenceError: d3 is not defined

推荐答案

要点是,您无法使用file://从javascript访问计算机上的文件(认为人们可以访问您的所有文件...).

The point is that you cannot access files on your computer from javascript using file:// (think that people could access all your file...).

因此,您必须在此处使用<script src="address/d3.js"></script>address对应于服务器的地址(http://domain.comhttp://localhost)或相对路径.

So you have to use <script src="address/d3.js"></script> here, address correspond to the address of your server (http://domain.com or http://localhost) or the relative path.

例如,您可以在html文件(相同的文件夹)旁边下载d3.js,只需键入<script src="d3.js"></script>

For example, you can download d3.js next to your html file (same folder) and just type <script src="d3.js"></script>

希望这会有所帮助

这篇关于D3.js starter(noob):如何从bl.ocks.org/mbostock工作中获取D3示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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