GWT 中的 d3-wordcloud
d3-wordcloud in GWT
我正在尝试在我的 GWT 项目中使用 d3-wordcloud(https://github.com/jasondavies/d3-cloud)。我将其包含在我的 .html 文件中:
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" language="javascript" src="d3.layout.cloud.js"></script>
<script type="text/javascript" language="javascript" src="main.js"></script>
其中 'main.js' 有一个包含此代码的方法:
d3.layout.cloud().size([width, height])
.timeInterval(20)
.words(word_entries)
.fontSize(function(d) { return xScale(+d.value); })
.text(function(d) { return d.key; })
.rotate(function() { return ~~(Math.random() * 2) * 90; })
.font("Impact")
.on("end", draw)
.start();
当我尝试从 .html 文件调用方法时,词云生成正常。但是当我从一个 java 文件(使用 $wnd)执行它时,我得到这个错误:
Uncaught TypeError: d3.layout.cloud is not a function' error
我认为这可能是因为 d3.layout.cloud.js 是用 node js 编写的,而 GWT 不知道如何使用它。
是这个原因吗?有解决方法吗?
附加信息:我使用 GWT 2.7。适合 java。零节点js技巧!
感觉你需要简单地使用 cloud()...
而不是 d3.layout.cloud()...
见第 10 行:https://github.com/jasondavies/d3-cloud/blob/master/examples/node.js
我正在尝试在我的 GWT 项目中使用 d3-wordcloud(https://github.com/jasondavies/d3-cloud)。我将其包含在我的 .html 文件中:
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" language="javascript" src="d3.layout.cloud.js"></script>
<script type="text/javascript" language="javascript" src="main.js"></script>
其中 'main.js' 有一个包含此代码的方法:
d3.layout.cloud().size([width, height])
.timeInterval(20)
.words(word_entries)
.fontSize(function(d) { return xScale(+d.value); })
.text(function(d) { return d.key; })
.rotate(function() { return ~~(Math.random() * 2) * 90; })
.font("Impact")
.on("end", draw)
.start();
当我尝试从 .html 文件调用方法时,词云生成正常。但是当我从一个 java 文件(使用 $wnd)执行它时,我得到这个错误:
Uncaught TypeError: d3.layout.cloud is not a function' error
我认为这可能是因为 d3.layout.cloud.js 是用 node js 编写的,而 GWT 不知道如何使用它。
是这个原因吗?有解决方法吗?
附加信息:我使用 GWT 2.7。适合 java。零节点js技巧!
感觉你需要简单地使用 cloud()...
而不是 d3.layout.cloud()...
见第 10 行:https://github.com/jasondavies/d3-cloud/blob/master/examples/node.js