Skip to content
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

Fix4631 - handle NaN cases to allow breaks on bar-like traces #4634

Merged
merged 2 commits into from
Mar 12, 2020
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
2 changes: 1 addition & 1 deletion src/traces/bar/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)
var sel = transition(Lib.ensureSingle(bar, 'path'), fullLayout, opts, makeOnCompleteCallback);
sel
.style('vector-effect', 'non-scaling-stroke')
.attr('d', 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z')
.attr('d', isNaN((x1 - x0) * (y1 - y0)) ? 'M0,0Z' : 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z')
.call(Drawing.setClipUrl, plotinfo.layerClipId, gd);

if(!fullLayout.uniformtext.mode && withTransition) {
Expand Down
83 changes: 82 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2876,7 +2876,7 @@ describe('bar tweening', function() {
data: [{
type: 'bar',
x: ['A', 'B', 'C'],
y: [null, 5, 3],
y: [null, 5, 3, 4],
marker: {
line: {
width: 10
Expand Down Expand Up @@ -2931,6 +2931,87 @@ describe('bar tweening', function() {
.catch(failTest)
.then(done);
});

it('handle NaN positions on vertical bars', function(done) {
var y1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var y2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
var mockCopy = {
data: [
{
type: 'bar',
x: [
0,
1,
'',
'NaN',
NaN,
Infinity,
-Infinity,
undefined,
null,
9
],
y: y1
}
],
layout: {
width: 400,
height: 300
}
};

var tests = [
[0, '.point path', 'attr', 'd', ['M2,120V109H22V120Z', 'M26,120V97H46V120Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M218,120V6H238V120Z']],
[300, '.point path', 'attr', 'd', ['M2,120V47H22V120Z', 'M26,120V49H46V120Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M218,120V68H238V120Z']],
[600, '.point path', 'attr', 'd', ['M2,120V6H22V120Z', 'M26,120V17H46V120Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M218,120V109H238V120Z']]
];
var animateOpts = {data: [{y: y2}]};

checkTransition(gd, mockCopy, animateOpts, transitionOpts, tests)
.catch(failTest)
.then(done);
});

it('handle NaN positions on horizontal bars', function(done) {
var x1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var x2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
var mockCopy = {
data: [
{
type: 'bar',
orientation: 'h',
y: [
0,
1,
'',
'NaN',
NaN,
Infinity,
-Infinity,
undefined,
null,
9
],
x: x1
}
],
layout: {
width: 400,
height: 300
}
};

var tests = [
[0, '.point path', 'attr', 'd', ['M0,119V109H23V119Z', 'M0,107V97H46V107Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,11V1H228V11Z']],
[300, '.point path', 'attr', 'd', ['M0,119V109H146V119Z', 'M0,107V97H141V107Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,11V1H105V11Z']],
[600, '.point path', 'attr', 'd', ['M0,119V109H228V119Z', 'M0,107V97H205V107Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,0Z', 'M0,11V1H23V11Z']]
];
var animateOpts = {data: [{x: x2}]};

checkTransition(gd, mockCopy, animateOpts, transitionOpts, tests)
.catch(failTest)
.then(done);
});
});

describe('bar uniformtext', function() {
Expand Down