diff --git a/src/traces/bar/plot.js b/src/traces/bar/plot.js index 8c3481b58c3..6f281d90d1e 100644 --- a/src/traces/bar/plot.js +++ b/src/traces/bar/plot.js @@ -107,9 +107,11 @@ module.exports = function plot(gd, plotinfo, cdModule, traceLayer) { var prefix; if(trace.type === 'waterfall') { - var cont = trace[di.dir].marker; - lw = cont.line.width; - mc = cont.color; + if(!isBlank) { + var cont = trace[di.dir].marker; + lw = cont.line.width; + mc = cont.color; + } prefix = 'waterfall'; } else { lw = (di.mlw + 1 || trace.marker.line.width + 1 || diff --git a/src/traces/waterfall/calc.js b/src/traces/waterfall/calc.js index 6cb7ded67ba..a5c9bcf0d98 100644 --- a/src/traces/waterfall/calc.js +++ b/src/traces/waterfall/calc.js @@ -90,7 +90,7 @@ module.exports = function calc(gd, trace) { } } - cd[0].hasTotals = hasTotals; + if(cd.length) cd[0].hasTotals = hasTotals; mergeArray(trace.text, cd, 'tx'); mergeArray(trace.hovertext, cd, 'htx'); diff --git a/src/traces/waterfall/style.js b/src/traces/waterfall/style.js index 12730615d9c..b893669df4f 100644 --- a/src/traces/waterfall/style.js +++ b/src/traces/waterfall/style.js @@ -25,13 +25,15 @@ function style(gd, cd) { var trace = d[0].trace; gTrace.selectAll('.point > path').each(function(di) { - var cont = trace[di.dir].marker; - - d3.select(this) - .call(Color.fill, cont.color) - .call(Color.stroke, cont.line.color) - .call(Drawing.dashLine, cont.line.dash, cont.line.width) - .style('opacity', trace.selectedpoints && !di.selected ? 0.3 : 1); + if(!di.isBlank) { + var cont = trace[di.dir].marker; + + d3.select(this) + .call(Color.fill, cont.color) + .call(Color.stroke, cont.line.color) + .call(Drawing.dashLine, cont.line.dash, cont.line.width) + .style('opacity', trace.selectedpoints && !di.selected ? 0.3 : 1); + } }); styleTextPoints(gTrace, trace, gd); diff --git a/test/jasmine/tests/waterfall_test.js b/test/jasmine/tests/waterfall_test.js index abce45ce1cd..67b8f33d2af 100644 --- a/test/jasmine/tests/waterfall_test.js +++ b/test/jasmine/tests/waterfall_test.js @@ -948,6 +948,36 @@ describe('A waterfall plot', function() { .then(done); }); + it('should be able to deal with blank bars on transform', function(done) { + Plotly.plot(gd, { + data: [{ + type: 'waterfall', + x: [1, 2, 3], + xsrc: 'ints', + transforms: [{ + type: 'filter', + target: [1, 2, 3], + targetsrc: 'ints', + operation: '<', + value: 0 + }] + }] + }) + .then(function() { + var traceNodes = getAllTraceNodes(gd); + var waterfallNodes = getAllWaterfallNodes(traceNodes[0]); + var pathNode = waterfallNodes[0].querySelector('path'); + + expect(gd.calcdata[0][0].x).toEqual(NaN); + expect(gd.calcdata[0][0].y).toEqual(NaN); + expect(gd.calcdata[0][0].isBlank).toBe(true); + + expect(pathNode.outerHTML).toEqual(''); + }) + .catch(failTest) + .then(done); + }); + it('should coerce text-related attributes', function(done) { var data = [{ y: [10, 20, 30, 40],