From 91e404cbc57548ebd9d71b299ca09a347a0f32fd Mon Sep 17 00:00:00 2001 From: Robert Monfera Date: Tue, 19 Sep 2017 15:52:07 +0200 Subject: [PATCH] render a thin but visible node even if `value` is very low --- src/traces/sankey/render.js | 2 +- test/jasmine/tests/sankey_test.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/traces/sankey/render.js b/src/traces/sankey/render.js index 1c33e111d64..848613c2272 100644 --- a/src/traces/sankey/render.js +++ b/src/traces/sankey/render.js @@ -182,7 +182,7 @@ function nodeModel(uniqueKeys, d, n) { zoneThicknessPad = c.nodePadAcross, zoneLengthPad = d.nodePad / 2, visibleThickness = n.dx + 0.5, - visibleLength = n.dy - 0.5; + visibleLength = Math.max(1, n.dy - 0.5); var basicKey = n.label; var foundKey = uniqueKeys[basicKey]; diff --git a/test/jasmine/tests/sankey_test.js b/test/jasmine/tests/sankey_test.js index 93f8f8b59e7..0ad914f7222 100644 --- a/test/jasmine/tests/sankey_test.js +++ b/test/jasmine/tests/sankey_test.js @@ -311,6 +311,29 @@ describe('sankey tests', function() { done(); }); }); + + it('\'node\' remains visible even if \'value\' is very low', function(done) { + + var gd = createGraphDiv(); + var minimock = [{ + type: 'sankey', + node: { + label: ['a', 'b1', 'b2'] + }, + link: { + source: [0, 0], + target: [1, 2], + value: [1000000, 0.001] + } + }]; + Plotly.plot(gd, minimock) + .then(function() { + expect(d3.selectAll('.sankey .nodeRect')[0].reduce(function(prevMin, rect) { + return Math.min(prevMin, d3.select(rect).attr('height')); + }, Infinity)).toEqual(1); + done(); + }); + }); }); describe('Test hover/click interactions:', function() {