File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -428,17 +428,21 @@ group2NA <- function(g, geom) {
428
428
is.group <- names(g $ data ) == " group"
429
429
poly.na.list <- list ()
430
430
forward.i <- seq_along(poly.list )
431
+ # # When group2NA is called on geom_polygon (or geom_rect, which is
432
+ # # treated as a basic polygon), we need to retrace the first points
433
+ # # of each group, see https://github.com/ropensci/plotly/pull/178
434
+ retrace.first.points <- g $ geom == " polygon"
431
435
for (i in forward.i ) {
432
436
no.group <- poly.list [[i ]][, ! is.group , drop = FALSE ]
433
437
na.row <- no.group [1 , ]
434
438
na.row [, c(" x" , " y" )] <- NA
435
- retrace.first <- if (g $ geom %in% c( " polygon " , " rect " ) ){
439
+ retrace.first <- if (retrace.first.points ){
436
440
no.group [1 ,]
437
441
}
438
442
poly.na.list [[paste(i , " forward" )]] <-
439
443
rbind(no.group , retrace.first , na.row )
440
444
}
441
- if (g $ geom %in% c( " polygon " , " rect " )){
445
+ if (retrace.first.points )){
442
446
backward.i <- rev(forward.i [- 1 ])[- 1 ]
443
447
for (i in backward.i ){
444
448
no.group <- poly.list [[i ]][1 , ! is.group , drop = FALSE ]
You can’t perform that action at this time.
0 commit comments