Skip to content

Commit 0782274

Browse files
authored
Merge pull request #3720 from plotly/fix3719-waterfall-transform-error
waterfall transform errors
2 parents 5abfe58 + be51caf commit 0782274

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

src/traces/bar/plot.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ module.exports = function plot(gd, plotinfo, cdModule, traceLayer) {
107107
var prefix;
108108

109109
if(trace.type === 'waterfall') {
110-
var cont = trace[di.dir].marker;
111-
lw = cont.line.width;
112-
mc = cont.color;
110+
if(!isBlank) {
111+
var cont = trace[di.dir].marker;
112+
lw = cont.line.width;
113+
mc = cont.color;
114+
}
113115
prefix = 'waterfall';
114116
} else {
115117
lw = (di.mlw + 1 || trace.marker.line.width + 1 ||

src/traces/waterfall/calc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module.exports = function calc(gd, trace) {
9090
}
9191
}
9292

93-
cd[0].hasTotals = hasTotals;
93+
if(cd.length) cd[0].hasTotals = hasTotals;
9494

9595
mergeArray(trace.text, cd, 'tx');
9696
mergeArray(trace.hovertext, cd, 'htx');

src/traces/waterfall/style.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ function style(gd, cd) {
2525
var trace = d[0].trace;
2626

2727
gTrace.selectAll('.point > path').each(function(di) {
28-
var cont = trace[di.dir].marker;
29-
30-
d3.select(this)
31-
.call(Color.fill, cont.color)
32-
.call(Color.stroke, cont.line.color)
33-
.call(Drawing.dashLine, cont.line.dash, cont.line.width)
34-
.style('opacity', trace.selectedpoints && !di.selected ? 0.3 : 1);
28+
if(!di.isBlank) {
29+
var cont = trace[di.dir].marker;
30+
31+
d3.select(this)
32+
.call(Color.fill, cont.color)
33+
.call(Color.stroke, cont.line.color)
34+
.call(Drawing.dashLine, cont.line.dash, cont.line.width)
35+
.style('opacity', trace.selectedpoints && !di.selected ? 0.3 : 1);
36+
}
3537
});
3638

3739
styleTextPoints(gTrace, trace, gd);

test/jasmine/tests/waterfall_test.js

+30
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,36 @@ describe('A waterfall plot', function() {
948948
.then(done);
949949
});
950950

951+
it('should be able to deal with blank bars on transform', function(done) {
952+
Plotly.plot(gd, {
953+
data: [{
954+
type: 'waterfall',
955+
x: [1, 2, 3],
956+
xsrc: 'ints',
957+
transforms: [{
958+
type: 'filter',
959+
target: [1, 2, 3],
960+
targetsrc: 'ints',
961+
operation: '<',
962+
value: 0
963+
}]
964+
}]
965+
})
966+
.then(function() {
967+
var traceNodes = getAllTraceNodes(gd);
968+
var waterfallNodes = getAllWaterfallNodes(traceNodes[0]);
969+
var pathNode = waterfallNodes[0].querySelector('path');
970+
971+
expect(gd.calcdata[0][0].x).toEqual(NaN);
972+
expect(gd.calcdata[0][0].y).toEqual(NaN);
973+
expect(gd.calcdata[0][0].isBlank).toBe(true);
974+
975+
expect(pathNode.outerHTML).toEqual('<path d="M0,0Z" style="vector-effect: non-scaling-stroke;"></path>');
976+
})
977+
.catch(failTest)
978+
.then(done);
979+
});
980+
951981
it('should coerce text-related attributes', function(done) {
952982
var data = [{
953983
y: [10, 20, 30, 40],

0 commit comments

Comments
 (0)