Skip to content

Fix #1328 skip translatePoint for empty nodes #1336

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 1 commit into from
Feb 2, 2017
Merged
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/components/drawing/index.js
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ drawing.translatePoint = function(d, sel, xa, ya) {
var x = d.xp || xa.c2p(d.x),
y = d.yp || ya.c2p(d.y);

if(isNumeric(x) && isNumeric(y)) {
if(isNumeric(x) && isNumeric(y) && sel.node()) {
// for multiline text this works better
if(sel.node().nodeName === 'text') {
sel.attr('x', x).attr('y', y);
22 changes: 22 additions & 0 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
@@ -178,6 +178,28 @@ describe('Test plot api', function() {
})
.then(done);
});

it('can set empty text nodes', function(done) {
var data = [{
x: [1, 2, 3],
y: [0, 0, 0],
text: ['', 'Text', ''],
mode: 'lines+text'
}];
var scatter = null;
var oldHeight = 0;
Plotly.plot(gd, data)
.then(function() {
scatter = document.getElementsByClassName('scatter')[0];
oldHeight = scatter.getBoundingClientRect().height;
return Plotly.relayout(gd, 'yaxis.range', [0.5, 0.5, 0.5]);
})
.then(function() {
var newHeight = scatter.getBoundingClientRect().height;
expect(newHeight).toEqual(oldHeight);
})
.then(done);
});
});

describe('Plotly.restyle', function() {