Skip to content

waterfall transform errors #3720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 6 additions & 4 deletions src/traces/bar/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ 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;
prefix = 'waterfall';
if(!isBlank) {
var cont = trace[di.dir].marker;
lw = cont.line.width;
mc = cont.color;
prefix = 'waterfall';
Copy link
Contributor

Choose a reason for hiding this comment

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

 prefix = 'waterfall';

is still well defined when isBlank:true, I'd leave it out of this block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for spotting that! Done in be51caf.

}
} else {
lw = (di.mlw + 1 || trace.marker.line.width + 1 ||
(di.trace ? di.trace.marker.line.width : 0) + 1) - 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