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

Skip to content

Shapes: nest shapelayers in .above and .below classed groups #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/shapes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ shapes.add = function(gd) {
// if opt is blank, val can be 'add' or a full options object to add a new
// annotation at that point in the array, or 'remove' to delete this one
shapes.draw = function(gd, index, opt, value) {
if(!isNumeric(index) || index===-1) {
if(!isNumeric(index) || index === -1) {
// no index provided - we're operating on ALL shapes
if(!index && Array.isArray(value)) {
replaceAllShapes(gd, value);
return;
}
else if(value==='remove') {
else if(value === 'remove') {
deleteAllShapes(gd);
return;
}
else if(opt && value!=='add') {
else if(opt && value !== 'add') {
updateAllShapes(gd, opt, value);
return;
}
Expand All @@ -147,11 +147,11 @@ shapes.draw = function(gd, index, opt, value) {
}

if(!opt && value) {
if(value==='remove') {
if(value === 'remove') {
deleteShape(gd, index);
return;
}
else if(value==='add' || Lib.isPlainObject(value)) {
else if(value === 'add' || Lib.isPlainObject(value)) {
insertShape(gd, index, value);
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2642,8 +2642,10 @@ function makePlotFramework(gd) {

// lower shape layer
// (only for shapes to be drawn below the whole plot)
fullLayout._shapeLowerLayer = fullLayout._paper.append('g')
.classed('shapelayer shapelayer-below', true);
var layerBelow = fullLayout._paper.append('g')
.classed('layer-below', true);
fullLayout._shapeLowerLayer = layerBelow.append('g')
.classed('shapelayer', true);

var subplots = Plotly.Axes.getSubplots(gd);
if(subplots.join('') !== Object.keys(gd._fullLayout._plots || {}).join('')) {
Expand All @@ -2661,8 +2663,10 @@ function makePlotFramework(gd) {

// upper shape layer
// (only for shapes to be drawn above the whole plot, including subplots)
fullLayout._shapeUpperLayer = fullLayout._paper.append('g')
.classed('shapelayer shapelayer-above', true);
var layerAbove = fullLayout._paper.append('g')
.classed('layer-above', true);
fullLayout._shapeUpperLayer = layerAbove.append('g')
.classed('shapelayer', true);

// single pie layer for the whole plot
fullLayout._pielayer = fullLayout._paper.append('g').classed('pielayer', true);
Expand Down
8 changes: 4 additions & 4 deletions test/jasmine/tests/shapes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ describe('Test shapes:', function() {
}

function countShapeLowerLayerNodes() {
return d3.selectAll('.shapelayer-below').size();
return d3.selectAll('.layer-below > .shapelayer').size();
}

function countShapeUpperLayerNodes() {
return d3.selectAll('.shapelayer-above').size();
return d3.selectAll('.layer-above > .shapelayer').size();
}

function countShapeLayerNodesInSubplots() {
Expand All @@ -66,11 +66,11 @@ describe('Test shapes:', function() {
}

function countShapePathsInLowerLayer() {
return d3.selectAll('.shapelayer-below > path').size();
return d3.selectAll('.layer-below > .shapelayer > path').size();
}

function countShapePathsInUpperLayer() {
return d3.selectAll('.shapelayer-above > path').size();
return d3.selectAll('.layer-above > .shapelayer > path').size();
}

function countShapePathsInSubplots() {
Expand Down