Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/traces/bar/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
2 changes: 1 addition & 1 deletion src/traces/waterfall/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
16 changes: 9 additions & 7 deletions src/traces/waterfall/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 30 additions & 0 deletions test/jasmine/tests/waterfall_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,36 @@ describe('A waterfall plot', function() {
.then(done);
});

it('should be able to deal with blank bars on transform', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10/10 test. Nice!

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('<path d="M0,0Z" style="vector-effect: non-scaling-stroke;"></path>');
})
.catch(failTest)
.then(done);
});

it('should coerce text-related attributes', function(done) {
var data = [{
y: [10, 20, 30, 40],
Expand Down