Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82c68a2

Browse files
committed
Shapes/Images: Reorganize above/below/subplot layers
1 parent 1903061 commit 82c68a2

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/components/shapes/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ shapes.drawAll = function(gd) {
9898
// Remove previous shapes before drawing new in shapes in fullLayout.shapes
9999
fullLayout._shapeUpperLayer.selectAll('path').remove();
100100
fullLayout._shapeLowerLayer.selectAll('path').remove();
101-
fullLayout._subplotShapeLayer.selectAll('path').remove();
101+
fullLayout._shapeSubplotLayer.selectAll('path').remove();
102102

103103
for(var i = 0; i < fullLayout.shapes.length; i++) {
104104
shapes.draw(gd, i);
@@ -356,7 +356,7 @@ function getShapeLayer(gd, index) {
356356
else if(shape.layer === 'below') {
357357
shapeLayer = (shape.xref === 'paper' && shape.yref === 'paper') ?
358358
gd._fullLayout._shapeLowerLayer :
359-
gd._fullLayout._subplotShapeLayer;
359+
gd._fullLayout._shapeSubplotLayer;
360360
}
361361

362362
return shapeLayer;

src/plot_api/plot_api.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,8 @@ function makePlotFramework(gd) {
26462646
.classed('layer-below', true);
26472647
fullLayout._shapeLowerLayer = layerBelow.append('g')
26482648
.classed('shapelayer', true);
2649+
fullLayout._imageLowerLayer = layerBelow.append('g')
2650+
.classed('imagelayer', true);
26492651

26502652
var subplots = Plotly.Axes.getSubplots(gd);
26512653
if(subplots.join('') !== Object.keys(gd._fullLayout._plots || {}).join('')) {
@@ -2658,15 +2660,18 @@ function makePlotFramework(gd) {
26582660
fullLayout._ternarylayer = fullLayout._paper.append('g').classed('ternarylayer', true);
26592661

26602662
// shape layers in subplots
2661-
fullLayout._subplotShapeLayer = fullLayout._paper
2662-
.selectAll('.shapelayer-subplot');
2663+
var layerSubplot = fullLayout._paper.selectAll('.layer-subplot');
2664+
fullLayout._shapeSubplotLayer = layerSubplot.selectAll('.shapelayer');
2665+
fullLayout._imageSubplotLayer = layerSubplot.selectAll('.imagelayer');
26632666

26642667
// upper shape layer
26652668
// (only for shapes to be drawn above the whole plot, including subplots)
26662669
var layerAbove = fullLayout._paper.append('g')
26672670
.classed('layer-above', true);
26682671
fullLayout._shapeUpperLayer = layerAbove.append('g')
26692672
.classed('shapelayer', true);
2673+
fullLayout._imageUpperLayer = layerAbove.append('g')
2674+
.classed('imagelayer', true);
26702675

26712676
// single pie layer for the whole plot
26722677
fullLayout._pielayer = fullLayout._paper.append('g').classed('pielayer', true);
@@ -2797,10 +2802,16 @@ function makeCartesianPlotFramwork(gd, subplots) {
27972802
// the plot and containers for overlays
27982803
plotinfo.bg = plotgroup.append('rect')
27992804
.style('stroke-width', 0);
2800-
// shape layer
2801-
// (only for shapes to be drawn below a subplot)
2802-
plotinfo.shapelayer = plotgroup.append('g')
2803-
.classed('shapelayer shapelayer-subplot', true);
2805+
2806+
// back layer for shapes and images to
2807+
// be drawn below a subplot
2808+
var backlayer = plotgroup.append('g')
2809+
.classed('layer-subplot', true);
2810+
2811+
plotinfo.shapelayer = backlayer.append('g')
2812+
.classed('shapelayer', true);
2813+
plotinfo.imagelayer = backlayer.append('g')
2814+
.classed('imagelayer', true);
28042815
plotinfo.gridlayer = plotgroup.append('g');
28052816
plotinfo.overgrid = plotgroup.append('g');
28062817
plotinfo.zerolinelayer = plotgroup.append('g');

0 commit comments

Comments
 (0)