Skip to content

Commit 0796e10

Browse files
committedFeb 2, 2017
Fix #1328 skip translatePoint for empty nodes
1 parent e7f69c9 commit 0796e10

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
 

‎src/components/drawing/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ drawing.translatePoint = function(d, sel, xa, ya) {
5151
var x = d.xp || xa.c2p(d.x),
5252
y = d.yp || ya.c2p(d.y);
5353

54-
if(isNumeric(x) && isNumeric(y)) {
54+
if(isNumeric(x) && isNumeric(y) && sel.node()) {
5555
// for multiline text this works better
5656
if(sel.node().nodeName === 'text') {
5757
sel.attr('x', x).attr('y', y);

‎test/jasmine/tests/plot_api_test.js

+22
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,28 @@ describe('Test plot api', function() {
178178
})
179179
.then(done);
180180
});
181+
182+
it('can set empty text nodes', function(done) {
183+
var data = [{
184+
x: [1, 2, 3],
185+
y: [0, 0, 0],
186+
text: ['', 'Text', ''],
187+
mode: 'lines+text'
188+
}];
189+
var scatter = null;
190+
var oldHeight = 0;
191+
Plotly.plot(gd, data)
192+
.then(function() {
193+
scatter = document.getElementsByClassName('scatter')[0];
194+
oldHeight = scatter.getBoundingClientRect().height;
195+
return Plotly.relayout(gd, 'yaxis.range', [0.5, 0.5, 0.5]);
196+
})
197+
.then(function() {
198+
var newHeight = scatter.getBoundingClientRect().height;
199+
expect(newHeight).toEqual(oldHeight);
200+
})
201+
.then(done);
202+
});
181203
});
182204

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

0 commit comments

Comments
 (0)
Please sign in to comment.