简体   繁体   English

使用可排序表时出现d3.v3错误?

[英]d3.v3 bug when working with sortable tables?

I have an example D3 Javascript code (located at here ) that creates tables, which mix text, links, and bar charts... using the D3.js library. 我有一个示例D3 Javascript代码(位于此处 ),该示例创建表,使用D3.js库混合文本,链接和条形图。

The Gist example works fine, in both Chrome and Safari, using the d3.v2.js version that is accessible via the path: Gist示例在chrome和Safari中都可以使用d3.v2.js版本,该版本可以通过以下路径访问:

<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.4.5"></script>

You can access the d3.v2.js source by following the path: " http://mbostock.github.com/d3/d3.js " (which appears to tell me that I'm pointing to version "d3.v2.js"). 您可以通过以下路径访问d3.v2.js源:“ http://mbostock.github.com/d3/d3.js ”(这似乎告诉我,我指向的版本是d3.v2。 js”)。

IMPORTANT: In this case, I know the code is working fine because the column of "Nodes" are all HTML hyperlinks that are "drillable." 重要信息:在这种情况下,我知道代码工作正常,因为“节点”列都是“可钻取”的HTML超链接。 The problem(s) seem to start when I try to use d3.v3... 当我尝试使用d3.v3时,问题似乎开始了。

NOTE: I downloaded d3.v3 and, using a local copy of the sortable table example (which readers can get from: http://bl.ocks.org/Guerino1/6366020 ). 注意:我下载了d3.v3,并使用了可排序表示例的本地副本(读者可以从http://bl.ocks.org/Guerino1/6366020获得)。 I pointed to the both versions of the d3.v3.js library (normal and minified) and get two different problems... 我指出了d3.v3.js库的两个版本(普通版和精简版),并遇到两个不同的问题...


PROBLEM #1: In the first case, I copied the un-minified file "d3.v3.js" to a local copy of "d3.js" and accessed it with the command: 问题1:在第一种情况下,我将未缩小的文件“ d3.v3.js”复制到“ d3.js”的本地副本中,并使用以下命令进行访问:

<script type="text/javascript" src="../LIBS/D3/d3.js"></script>

When I do this, I get an error in the d3.js file that reads " [Error] SyntaxError: Invalid character '\荤' (d3.js, line 1175) " Also, in this case, the column of Nodes does not turn into a hyperlink (ie the full path of the link gets rendered as text, rather than a hyperlink). 当我这样做时,我在d3.js文件中收到一个错误,该错误显示为“ [错误]语法错误:无效字符'\\ u8364'(d3.js,第1175行) ”另外,在这种情况下,“节点”列不会变成超链接(即,链接的完整路径将呈现为文本,而不是超链接)。 ( This is consistent in, both, Chrome and Safari. ) 这在Chrome和Safari中都是一致的。


PROBLEM #2: In the second case, I copied the minified file "d3.v3/d3.v3.min.js" to a local copy of d3.js and accessed it using the same path, above. 问题2:在第二种情况下,我将缩小的文件“ d3.v3 / d3.v3.min.js”复制到d3.js的本地副本中,并使用上面相同的路径进行访问。 In this second case, I get no error but the Nodes in the first column still do not turn into hyperlinks (ie the full path of the link gets rendered as text, rather than a hyperlink). 在第二种情况下,我没有收到任何错误,但是第一列中的节点仍然没有变成超链接(即,链接的完整路径被呈现为文本,而不是超链接)。 ( This is consistent in, both, Chrome and Safari. ) 这在Chrome和Safari中都是一致的。

D3 in version 3 uses unicode characters in some of the code as variables names (in particular Greek letters in the projection code). 版本3中的D3在某些代码中使用unicode字符作为变量名称(尤其是投影代码中的希腊字母)。 When including the script, you need specify the character encoding, ie 包含脚本时,需要指定字符编码,即

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>

Note the charset="utf-8" . 注意charset="utf-8"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM