text: $(window).on("load",function(){var t=d3.select("#vertical-sankey"),n=20,e=20,r=30,a=50,o=t.node().getBoundingClientRect().width-a-e,d=650-n-r,i=d3.format(",.0f"),l=function(t){return i(t)+"m CHF"},s=d3.scale.ordinal().range(["#99B898","#FECEA8","#FF847C","#E84A5F","#F8B195","#F67280","#C06C84"]),c=t.append("svg").attr("width",o+a+e).attr("height",d+n+r).append("g").attr("transform","translate("+a+","+n+")"),u=d3.sankey().nodeWidth(25).nodePadding(20).size([o,d]),p=u.link();d3.json("../../../app-assets/data/d3/other/sankey.json",function(t,n){if(t)throw t;u.nodes(n.nodes).links(n.links).layout(32);var e=c.append("g").selectAll(".link").data(n.links).enter().append("path").attr("class","link").attr("d",p).style("stroke-width",function(t){return Math.max(1,t.dy)}).style("stroke",function(t){return t.source.color=s(t.source.name.replace(/ .*/,""))}).style("fill","none").style("stroke-opacity","0.5").sort(function(t,n){return n.dy-t.dy});e.append("title").text(function(t){return t.source.name+" → "+t.target.name+"\n"+l(t.value)});var r=c.append("g").selectAll(".node").data(n.nodes).enter().append("g").attr("class","node").attr("transform",function(t){return"translate("+t.x+","+t.y+")"}).call(d3.behavior.drag().origin(function(t){return t}).on("dragstart",function(){this.parentNode.appendChild(this)}).on("drag",function(t){d3.select(this).attr("transform","translate("+(t.x=Math.max(0,Math.min(o-t.dy,d3.event.x)))+","+t.y+")"),u.relayout(),e.attr("d",p)}));r.append("rect").attr("height",u.nodeWidth()).attr("width",function(t){return t.dy}).style("fill",function(t){return t.color=s(t.name.replace(/ .*/,""))}).style("stroke",function(t){return d3.rgb(t.color).darker(2)}).style("fill-opacity","0.9").append("title").text(function(t){return t.name+"\n"+l(t.value)}),r.append("text").attr("text-anchor","middle").attr("x",function(t){return t.dy/2}).attr("y",u.nodeWidth()/2).attr("dy",".35em").text(function(t){return t.name}).filter(function(t){return t.x<o/2})})});