[英]json passing to D3
I am trying to load data into a D3 script but have difficulties getting the data prosessed in the Dendogranm example. 我正在尝试将数据加载到D3脚本中,但是在Dendogranm示例中很难对数据进行处理。 The data comes from the server as follows:
数据来自服务器,如下所示:
d3.json( [{"name": "flare", "children": [{"name": "analytics", "children": [{"name": "cluster", "children": [{"name": "AgglomerativeCluster", "size": 3938}, {"name": "CommunityStructure", "size": 3812}, {"name": "HierarchicalCluster", "size": 6714}, etc
The following error occurs in the cluster creation: "Uncaught TypeError: Cannot set property 'depth' of undefined" 在群集创建中会发生以下错误:“未捕获的TypeError:无法设置未定义的属性'depth'”
var nodes = cluster.nodes(root),
links = cluster.links(nodes);
So d3.json is not the proper construct. 因此d3.json不是正确的构造。 I assume this must be changed to
我认为这必须更改为
var flare = [{"name": "flare", "children": [{"name": "analyti ...
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(40,0)");
var nodes = cluster.nodes( flare ),
links = cluster.links(nodes);
var link = svg.selectAll(".link")
.data(links)
.enter().append("path")
Kinds regards supporting me. 亲切的问候支持我。
I experienced this same error, it was because I was trying to define a pack layout without setting the width and height properly. 我遇到了同样的错误,这是因为我试图定义包装布局而没有正确设置宽度和高度。
If your cluster
variable was defined like: 如果您的
cluster
变量定义如下:
var cluster = d3.layout.pack()
.size([width, height])
.value(function(d) {
return d.values;
});
That should work for you. 那应该为您工作。
d.values
would refer to a size (number) d.values
将引用大小(数字)
I believe that flare
also needs to be an object instead of an array. 我相信,
flare
也需要成为对象而不是数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.