Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Commit 91e404c

Browse files
committed
render a thin but visible node even if value is very low
1 parent 790d470 commit 91e404c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/traces/sankey/render.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function nodeModel(uniqueKeys, d, n) {
182182
zoneThicknessPad = c.nodePadAcross,
183183
zoneLengthPad = d.nodePad / 2,
184184
visibleThickness = n.dx + 0.5,
185-
visibleLength = n.dy - 0.5;
185+
visibleLength = Math.max(1, n.dy - 0.5);
186186

187187
var basicKey = n.label;
188188
var foundKey = uniqueKeys[basicKey];

test/jasmine/tests/sankey_test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,29 @@ describe('sankey tests', function() {
311311
done();
312312
});
313313
});
314+
315+
it('\'node\' remains visible even if \'value\' is very low', function(done) {
316+
317+
var gd = createGraphDiv();
318+
var minimock = [{
319+
type: 'sankey',
320+
node: {
321+
label: ['a', 'b1', 'b2']
322+
},
323+
link: {
324+
source: [0, 0],
325+
target: [1, 2],
326+
value: [1000000, 0.001]
327+
}
328+
}];
329+
Plotly.plot(gd, minimock)
330+
.then(function() {
331+
expect(d3.selectAll('.sankey .nodeRect')[0].reduce(function(prevMin, rect) {
332+
return Math.min(prevMin, d3.select(rect).attr('height'));
333+
}, Infinity)).toEqual(1);
334+
done();
335+
});
336+
});
314337
});
315338

316339
describe('Test hover/click interactions:', function() {

0 commit comments

Comments
 (0)