File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -638,7 +638,8 @@ function addNewShapes(outlines, dragOptions) {
638
638
dragmode = 'linedraw' ;
639
639
break ;
640
640
case 'path' :
641
- if ( d [ d . length - 1 ] === 'Z' ) {
641
+ var path = gd . _fullLayout . shapes [ id ] . path || '' ;
642
+ if ( path [ path . length - 1 ] === 'Z' ) {
642
643
dragmode = 'closedfreedraw' ;
643
644
} else {
644
645
dragmode = 'openfreedraw' ;
@@ -651,6 +652,15 @@ function addNewShapes(outlines, dragOptions) {
651
652
652
653
var newShapes = [ ] ;
653
654
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
+ }
654
664
for ( var i = 0 ; i < polygons . length ; i ++ ) {
655
665
var cell = polygons [ i ] ;
656
666
var len = cell . length ;
You can’t perform that action at this time.
0 commit comments