From 4626de081953705b4538f6f985133a2b4b4fb0b8 Mon Sep 17 00:00:00 2001 From: Rupert Curwen Date: Fri, 11 Apr 2014 10:30:59 +0100 Subject: [PATCH] Added option to turn off "moveSinksRight" Sometimes you just don't want your sinks in the right stack! --- sankey/sankey.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sankey/sankey.js b/sankey/sankey.js index c3bc59f..e5db1e9 100644 --- a/sankey/sankey.js +++ b/sankey/sankey.js @@ -4,7 +4,8 @@ d3.sankey = function() { nodePadding = 8, size = [1, 1], nodes = [], - links = []; + links = [], + sinksRight = true; sankey.nodeWidth = function(_) { if (!arguments.length) return nodeWidth; @@ -36,6 +37,12 @@ d3.sankey = function() { return sankey; }; + sankey.sinksRight = function (_) { + if (!arguments.length) return sinksRight; + sinksRight = _; + return sankey; + }; + sankey.layout = function(iterations) { computeNodeLinks(); computeNodeValues(); @@ -126,7 +133,7 @@ d3.sankey = function() { } // - moveSinksRight(x); + if (sinksRight) moveSinksRight(x); scaleNodeBreadths((size[0] - nodeWidth) / (x - 1)); }