Skip to content

Commit 1040786

Browse files
committed
improve edit open paths
1 parent 0c495e1 commit 1040786

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/plots/cartesian/new_shape.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ function addNewShapes(outlines, dragOptions) {
638638
dragmode = 'linedraw';
639639
break;
640640
case 'path':
641-
if(d[d.length - 1] === 'Z') {
641+
var path = gd._fullLayout.shapes[id].path || '';
642+
if(path[path.length - 1] === 'Z') {
642643
dragmode = 'closedfreedraw';
643644
} else {
644645
dragmode = 'openfreedraw';
@@ -651,6 +652,15 @@ function addNewShapes(outlines, dragOptions) {
651652

652653
var newShapes = [];
653654
var polygons = readPaths(d, plotinfo, gd._fullLayout._size, isActiveShape);
655+
if(isOpenMode) {
656+
var last = polygons[0].length - 1;
657+
if( // ensure first and last positions are not the same on an open path
658+
polygons[0][0][0] === polygons[0][last][0] &&
659+
polygons[0][0][1] === polygons[0][last][1]
660+
) {
661+
polygons[0].pop();
662+
}
663+
}
654664
for(var i = 0; i < polygons.length; i++) {
655665
var cell = polygons[i];
656666
var len = cell.length;

0 commit comments

Comments
 (0)