I\'m looking at this example that uses cluster layout to assign the X and Y coordinates to nodes on a dendrogram. How can I tell cluster to layout vertically, top down, instead
For the example you link, just flip the use of the X and Y coordinates. This can be done by changing
var diagonal = d3.svg.diagonal()
.projection(function(d) { return [d.y, d.x]; });
and
var node = vis.selectAll("g.node")
.data(nodes)
.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
to
var diagonal = d3.svg.diagonal()
// Flip the values here.
.projection(function(d) { return [d.x, d.y]; });
and
var node = vis.selectAll("g.node")
.data(nodes)
.enter().append("g")
.attr("class", "node")
// Flip the values here.
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; })
Here is a JSFiddle showing the above changes in action.