@@ -179,16 +179,13 @@ plotly_build.plotly <- function(p) {
179179 # are combined into a single grouping variable, .plotlyGroupIndex
180180 builtData <- arrange_safe(builtData , " .plotlyTraceIndex" )
181181 isComplete <- complete.cases(builtData [names(builtData ) %in% c(" x" , " y" , " z" )])
182- # is grouping relevant for this geometry? (e.g., grouping doesn't effect a scatterplot)
183- hasGrp <- inherits(trace , paste0(" plotly_" , c(" segment" , " path" , " line" , " polygon" ))) ||
184- (grepl(" scatter" , trace [[" type" ]]) && grepl(" lines" , trace [[" mode" ]]))
185182 # warn about missing values if groups aren't relevant for this trace type
186- if (any(! isComplete ) && ! hasGrp ) {
183+ if (any(! isComplete ) && ! has_group( trace ) ) {
187184 warning(" Ignoring " , sum(! isComplete ), " observations" , call. = FALSE )
188185 }
189186 builtData [[" .plotlyMissingIndex" ]] <- cumsum(! isComplete )
190187 builtData <- builtData [isComplete , ]
191- if (length(grps ) && hasGrp && isTRUE(trace [[" connectgaps" ]])) {
188+ if (length(grps ) && has_group( trace ) && isTRUE(trace [[" connectgaps" ]])) {
192189 stop(
193190 " Can't use connectgaps=TRUE when data has group(s)." , call. = FALSE
194191 )
@@ -229,7 +226,8 @@ plotly_build.plotly <- function(p) {
229226 traces <- lapply(traces , function (x ) {
230227 d <- data.frame (x [names(x ) %in% x $ .plotlyVariableMapping ], stringsAsFactors = FALSE )
231228 d <- group2NA(
232- d , " .plotlyGroupIndex" , ordered = if (inherits(x , " plotly_line" )) " x" ,
229+ d , if (has_group(x )) " .plotlyGroupIndex" ,
230+ ordered = if (inherits(x , " plotly_line" )) " x" ,
233231 retrace.first = inherits(x , " plotly_polygon" )
234232 )
235233 for (i in x $ .plotlyVariableMapping ) {
0 commit comments