diff --git a/src/components/drawing/index.js b/src/components/drawing/index.js index 2b1c733df98..2f0b99c0f9f 100644 --- a/src/components/drawing/index.js +++ b/src/components/drawing/index.js @@ -52,7 +52,9 @@ drawing.font = function(s, family, size, color) { * instead, so that elements get updated to match. */ drawing.setPosition = function(s, x, y) { s.attr('x', x).attr('y', y); }; -drawing.setSize = function(s, w, h) { s.attr('width', w).attr('height', h); }; +drawing.setSize = function(s, w, h) { + s.attr('width', w < 0 ? 0 : w).attr('height', h < 0 ? 0 : h); +}; drawing.setRect = function(s, x, y, w, h) { s.call(drawing.setPosition, x, y).call(drawing.setSize, w, h); }; diff --git a/src/plot_api/subroutines.js b/src/plot_api/subroutines.js index fa74da9e967..63a707db7a2 100644 --- a/src/plot_api/subroutines.js +++ b/src/plot_api/subroutines.js @@ -174,8 +174,8 @@ exports.lsInner = function(gd) { }); plotClip.select('rect').attr({ - width: xa._length, - height: ya._length + width: xa._length < 0 ? 0 : xa._length, + height: ya._length < 0 ? 0 : ya._length }); Drawing.setTranslate(plotinfo.plot, xa._offset, ya._offset); diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index c44db0c9856..a405313b87f 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -1488,8 +1488,8 @@ axes.makeClipPaths = function(gd) { d3.select(this).select('rect').attr({ x: d.x._offset || 0, y: d.y._offset || 0, - width: d.x._length || 1, - height: d.y._length || 1 + width: (d.x._length < 0 ? 0 : d.x._length) || 1, + height: (d.y._length < 0 ? 0 : d.y._length) || 1 }); }); };