0
我目前正试图自定义一个例子,如... http://bl.ocks.org/1377729使用D3.json函数来获取json数据。使用D3.json函数导入json数据
此刻,我一直在努力做到这一点:
d3.json("http:", function(json) {
var nodes = [];
var labelAnchors = [];
在这里,我试图导入的功能,但它没有做任何事情
for(var i = 0; i < 30; i++) {
var node = json;
nodes.push(node);
labelAnchors.push({
node : node
});
labelAnchors.push({
node : node
});
};
我也试图把函数进入.text函数
anchorNode.append("svg:text")
.text(function(d, i) {return i % 2 == 0 ? "" : d.node.json })
.style("fill", "#555")
.style("font-family", "Arial")
.style("font-size", 12);
有谁能告诉我哪里出错了请!
您的json网址未显示完成。 https://github.com/mbostock/d3/wiki/Requests#wiki-d3_json – nautat
嗨@nautat我故意错过了那部分了..是否还有其他什么是错的? – user1701622
你能分享一下你的json数据结构吗?从您引用的示例中,可以看到节点和labelAnchors是对象的数组(长度为30)。它们的节点对象如下所示:{label:“node0”}并形成节点数组。形成labelAnchors数组的对象如下所示:{node:{label:“node0”}}。 – nautat