Skip to content

Commit c4b811c

Browse files
committed
ensure waterfall connector lines cliped when there is an axis break
1 parent b52e990 commit c4b811c

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

src/traces/waterfall/plot.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var d3 = require('d3');
1212
var Lib = require('../../lib');
1313
var Drawing = require('../../components/drawing');
14+
var BADNUM = require('../../constants/numerical').BADNUM;
1415
var barPlot = require('../bar/plot');
1516
var clearMinTextSize = require('../bar/uniform_text').clearMinTextSize;
1617

@@ -66,31 +67,36 @@ function plotConnectors(gd, plotinfo, cdModule, traceLayer) {
6667

6768
var shape = '';
6869

69-
if(mode === 'spanning') {
70-
if(!di.isSum && i > 0) {
71-
if(isHorizontal) {
72-
shape += 'M' + x[0] + ',' + y[1] + 'V' + y[0];
73-
} else {
74-
shape += 'M' + x[1] + ',' + y[0] + 'H' + x[0];
70+
if(
71+
x[0] !== BADNUM && y[0] !== BADNUM &&
72+
x[1] !== BADNUM && y[1] !== BADNUM
73+
) {
74+
if(mode === 'spanning') {
75+
if(!di.isSum && i > 0) {
76+
if(isHorizontal) {
77+
shape += 'M' + x[0] + ',' + y[1] + 'V' + y[0];
78+
} else {
79+
shape += 'M' + x[1] + ',' + y[0] + 'H' + x[0];
80+
}
7581
}
7682
}
77-
}
7883

79-
if(mode !== 'between') {
80-
if(di.isSum || i < len - 1) {
81-
if(isHorizontal) {
82-
shape += 'M' + x[1] + ',' + y[0] + 'V' + y[1];
83-
} else {
84-
shape += 'M' + x[0] + ',' + y[1] + 'H' + x[1];
84+
if(mode !== 'between') {
85+
if(di.isSum || i < len - 1) {
86+
if(isHorizontal) {
87+
shape += 'M' + x[1] + ',' + y[0] + 'V' + y[1];
88+
} else {
89+
shape += 'M' + x[0] + ',' + y[1] + 'H' + x[1];
90+
}
8591
}
8692
}
87-
}
8893

89-
if(x[2] !== undefined && y[2] !== undefined) {
90-
if(isHorizontal) {
91-
shape += 'M' + x[1] + ',' + y[1] + 'V' + y[2];
92-
} else {
93-
shape += 'M' + x[1] + ',' + y[1] + 'H' + x[2];
94+
if(x[2] !== BADNUM && y[2] !== BADNUM) {
95+
if(isHorizontal) {
96+
shape += 'M' + x[1] + ',' + y[1] + 'V' + y[2];
97+
} else {
98+
shape += 'M' + x[1] + ',' + y[1] + 'H' + x[2];
99+
}
94100
}
95101
}
96102

0 commit comments

Comments
 (0)