I have a json file with the following elements:
[{
"name": "Manuel Jose",
"ttags": ["vivant", "designer", "artista", "empreendedor"]
}]
I am trying to get node and edges using this structure to finish a graph, for example:

(diagram taken from d3.js documentation )
Both nameand ttagsin my json file refer to the nodes ttagsare actually connections between the node and other nodes.
But I can’t figure out how to create this diagram using this d3 library and above json file.
d3.json("/data/tedxufrj.json", function(classes) {
var nodes = cluster.nodes(package.root(classes)),
links = package.imports(nodes);
vis.selectAll("path.link")
.data(splines = bundle(links))
.enter().append("path")
.attr("class", "link")
.attr("d", line);
vis.selectAll("g.node")
.data(nodes.filter(function(n) { return !n.children; }))
.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; })
.append("text")
.attr("dx", function(d) { return d.x < 180 ? 8 : -8; })
.attr("dy", ".31em")
.attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
.attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
.text(function(d) { return d.key; });
});
And this is the package.js file:
(function() {
packages = {
root: function(classes) {
var map = {};
function find(name, data) {
var node = map[name], i;
if (!node) {
node = map[name] = data || {name: name, children: []};
if (name.length) {
node.parent = find(name.substring(0, i = name.lastIndexOf(".")));
node.parent.children.push(node);
node.key = name.substring(i + 1);
}
}
return node;
}
classes.forEach(function(d) {
find(d.name, d);
});
return map[""];
},
imports: function(nodes) {
var map = {},
imports = [];
nodes.forEach(function(d) {
map[d.name] = d;
});
nodes.forEach(function(d) {
if (d.imports) d.imports.forEach(function(i) {
imports.push({source: map[d.name], target: map[i]});
});
});
return imports;
}
};
})();