I want to add titles above each column of nodes in a D3.js Sankey diagram. For example, I take this example: http://bl.ocks.org/d3noob/5028304 and this is the result I want:
I thought something like this but it doesn't convince me. I'm looking for other alternatives.
var columnNames=["step 1","step 2","step 3","step 4"];
var distance=width/(columnNames.length-1);
var pos=0;
for (var i = 0; i < columnNames.length; i++){
svg.append("text")
.attr("x", pos)
.text(columnNames[i]);
pos=pos+distance;
}
How can I do that?
Thank you in advance.