translate breaks if selection is empty
1wheel opened this issue · 1 comments
1wheel commented
need to exit early from this if node doesn't exist
return this.node().getBBox ?
this.attr('transform', function(d,i) {
var p = typeof xy == 'function' ? xy.call(this, d,i) : xy;
if (dim === 0) p = [p, 0]; else if (dim === 1) p = [0, p];
return 'translate(' + p[0] +','+ p[1]+')';
}) :
1wheel commented
quick fix
var translateSelection = function(xy, dim) {
var node = this.node()
return !node ? this : node.getBBox ?
this.attr('transform', function(d,i) {
var p = typeof xy == 'function' ? xy.call(this, d,i) : xy;
if (dim === 0) p = [p, 0]; else if (dim === 1) p = [0, p];
return 'translate(' + p[0] +','+ p[1]+')';
}) :
this.style('transform', function(d,i) {
var p = typeof xy == 'function' ? xy.call(this, d,i) : xy;
if (dim === 0) p = [p, 0]; else if (dim === 1) p = [0, p];
return 'translate(' + p[0] +'px,'+ p[1]+'px)';
});
};