From 4d1c0712cf12f8077e0bfa1da45a21f9b9db67fe Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Wed, 25 Feb 2015 14:30:49 -0800 Subject: [PATCH] sankey: fix nodesByBreadth to have proper ordering d3.nest().key() converts all keys into strings. d3.ascending does not coerce strings into numbers for comparison -- do it ourselves. This improves relaxation efficiency. Before, it could traverse levels in the wrong orders, taking longer to propagate values up. --- sankey/sankey.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sankey/sankey.js b/sankey/sankey.js index abe137b..ffc8be9 100644 --- a/sankey/sankey.js +++ b/sankey/sankey.js @@ -157,7 +157,7 @@ d3.sankey = function() { function computeNodeDepths(iterations) { var nodesByBreadth = d3.nest() .key(function(d) { return d.x; }) - .sortKeys(d3.ascending) + .sortKeys(function(a, b) { return a - b; }) .entries(nodes) .map(function(d) { return d.values; });