admin管理员组文章数量:1295783
I have this in my index.html
file but it does not show the paragraph that I want to add with D3
<!DOCTYPE html>
<html>
<head>
<title> D3 page template </title>
<script type="text/javascript" src = "d3/d3.v3.js"></script>
</head>
<body>
<script type="text/javascript">
d3.select("body").append("p").text("new paragraph!");
</script>
</body>
</html>
The path to where I am referencing D3.js
should be correct because if I do an inspect element in the browser I can click on the D3
link and it takes me to its source code.
I have this in my index.html
file but it does not show the paragraph that I want to add with D3
<!DOCTYPE html>
<html>
<head>
<title> D3 page template </title>
<script type="text/javascript" src = "d3/d3.v3.js"></script>
</head>
<body>
<script type="text/javascript">
d3.select("body").append("p").text("new paragraph!");
</script>
</body>
</html>
The path to where I am referencing D3.js
should be correct because if I do an inspect element in the browser I can click on the D3
link and it takes me to its source code.
- 2 Use d3js.org/d3.v3.min.js in src for d3 – Prasath K Commented May 21, 2013 at 13:14
- also attached the picture of the error I get. – user1899082 Commented May 21, 2013 at 13:19
- @PrasathK : hmm yeah it worked with directly referencing it from the web site but WHY the local one is not working? – user1899082 Commented May 21, 2013 at 13:21
- You might have referenced wrongly – Prasath K Commented May 21, 2013 at 13:21
- but when I click on it in debugger, it does go to its source code. – user1899082 Commented May 21, 2013 at 13:22
3 Answers
Reset to default 16You are missing the character set in your HTML page. Add something like this:
<meta charset="utf-8">
The un-minified source of D3 includes the actual symbol for pi, which confuses the browser if the character set is not defined.
I am going to assume that you are testing this out without a web server. If so, then your URL will read file://.... not http://..
With this, the Javascript request will go to file:///.../D3/d3/d3.v3.js which won't have the proper response header set, such as charset and MIME.
You can always get it from a CDN to avoid this problem:
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
Was having similar issue. My problem was my script file was loading before it could load the d3js library. Just adding defer
fixed the issue.
<script src="app.js" defer></script>
本文标签: javascriptSimplest D3js example not workingStack Overflow
版权声明:本文标题:javascript - Simplest D3.js example not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738462797a2088126.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论