@@ -131,28 +131,24 @@ plotly_build.plotly <- function(p, registerFrames = TRUE) {
131
131
class = oldClass(x )
132
132
)
133
133
134
+ # determine trace type (if not specified, can depend on the # of data points)
135
+ # note that this should also determine a sensible mode, if appropriate
136
+ trace <- verify_type(trace )
137
+ # verify orientation of boxes/bars
138
+ trace <- verify_orientation(trace )
139
+
134
140
# attach crosstalk info, if necessary
135
141
if (crosstalk_key() %in% names(dat ) && isTRUE(trace [[" inherit" ]] %|| % TRUE )) {
136
142
trace [[" key" ]] <- trace [[" key" ]] %|| % dat [[crosstalk_key()]]
137
143
trace [[" set" ]] <- trace [[" set" ]] %|| % attr(dat , " set" )
138
144
}
139
145
140
146
# if appropriate, tack on a group index
141
- grps <- tryCatch(
142
- as.character(dplyr :: groups(dat )),
143
- error = function (e ) character (0 )
144
- )
145
-
147
+ grps <- if (has_group(trace )) dplyr :: group_vars(dat )
146
148
if (length(grps ) && any(lengths(trace ) == NROW(dat ))) {
147
149
trace [[" .plotlyGroupIndex" ]] <- interaction(dat [, grps , drop = F ])
148
150
}
149
151
150
- # determine trace type (if not specified, can depend on the # of data points)
151
- # note that this should also determine a sensible mode, if appropriate
152
- trace <- verify_type(trace )
153
- # verify orientation of boxes/bars
154
- trace <- verify_orientation(trace )
155
-
156
152
# add sensible axis names to layout
157
153
for (i in c(" x" , " y" , " z" )) {
158
154
nm <- paste0(i , " axis" )
0 commit comments