packages/xebra.js/examples/09-d3js/web/app.js
function update() {
	var stateTree = buildTreeJSON(xebraState.getPatchers());
	var nodes = d3.hierarchy(stateTree, function(d) {
		return d.children;
	});
	d3Tree(nodes);

	var link = g.selectAll(".link")
		.data(nodes.descendants().slice(1))
	.enter().append("path")
		.attr("class", "link")
		.attr("d", diagonal);

	var node = g.selectAll(".node")
		.data(nodes.descendants())
	.enter().append("g")
		.attr("class", function(d) { return "node" + (d.children ? " node--internal" : " node--leaf"); })
		.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });

	node.append("circle")
		.attr("r", 2.5);

	node.append("text")
		.attr("dy", function(d) { return d.children ? -10 : 0 })
		.attr("x", function(d) { return d.children ? -8 : 8; })
		.style("text-anchor", "start" )
		.text(function(d) { return d.data.name; });
}
function update() {
	var stateTree = buildTreeJSON(xebraState.getPatchers());
	var nodes = d3.hierarchy(stateTree, function(d) {
		return d.children;
	});
	d3Tree(nodes);

	var link = g.selectAll(".link")
		.data(nodes.descendants().slice(1))
	.enter().append("path")
		.attr("class", "link")
		.attr("d", diagonal);

	var node = g.selectAll(".node")
		.data(nodes.descendants())
	.enter().append("g")
		.attr("class", function(d) { return "node" + (d.children ? " node--internal" : " node--leaf"); })
		.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });

	node.append("circle")
		.attr("r", 2.5);

	node.append("text")
		.attr("dy", function(d) { return d.children ? -10 : 0 })
		.attr("x", function(d) { return d.children ? -8 : 8; })
		.style("text-anchor", "start" )
		.text(function(d) { return d.data.name; });
}
D3 Update function