Skip to content

Commit be61173

Browse files
committed
shapes: fix #611 (shapes and overlaid axis)
* Only draw shapes in main subplots.
1 parent b5f8707 commit be61173

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/shapes/index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ function updateShape(gd, index, opt, value) {
325325
plotinfo = plots[subplots[i]];
326326
clipAxes = subplots[i];
327327

328-
if(isShapeInSubplot(gd, options, plotinfo.id)) {
328+
if(isShapeInSubplot(gd, options, plotinfo)) {
329329
drawShape(plotinfo.shapelayer);
330330
}
331331
}
@@ -362,10 +362,13 @@ function getShapeLayer(gd, index) {
362362
return shapeLayer;
363363
}
364364

365-
function isShapeInSubplot(gd, shape, subplot) {
366-
var xa = Plotly.Axes.getFromId(gd, subplot, 'x')._id,
367-
ya = Plotly.Axes.getFromId(gd, subplot, 'y')._id;
368-
return shape.layer === 'below' && (xa === shape.xref || ya === shape.yref);
365+
function isShapeInSubplot(gd, shape, plotinfo) {
366+
var xa = Plotly.Axes.getFromId(gd, plotinfo.id, 'x')._id,
367+
ya = Plotly.Axes.getFromId(gd, plotinfo.id, 'y')._id,
368+
isBelow = shape.layer === 'below',
369+
inSuplotAxis = (xa === shape.xref || ya === shape.yref),
370+
isNotAnOverlaidSubplot = !!plotinfo.shapelayer;
371+
return isBelow && inSuplotAxis && isNotAnOverlaidSubplot;
369372
}
370373

371374
function decodeDate(convertToPx) {

0 commit comments

Comments
 (0)