最简单的D3.js示例不工作

最简单的D3.js示例不工作

问题描述:

我在 index.html 文件中有这个,但它不显示我想用 D3 $ c $添加的段落c>

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>

我参考的路径 D3.js 应该是正确的,因为如果我在浏览器中做一个检查元素,我可以点击 D3 链接,它需要我的源代码。

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.

您的HTML页面中缺少字符集。添加如下内容:

You are missing the character set in your HTML page. Add something like this:

<meta charset="utf-8">

D3的未缩减源包括pi的实际符号,如果字符set未定义。

The un-minified source of D3 includes the actual symbol for pi, which confuses the browser if the character set is not defined.