Skip to content

Commit d01dfe8

Browse files
committed
plotly_build should always return a plotly object
1 parent c495255 commit d01dfe8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

R/plotly.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ plotly_build <- function(l = get_plot()) {
191191
# plots without NSE don't need it either
192192
nms <- lapply(l$data, names)
193193
idx <- unique(unlist(lapply(l$data, names))) %in% c("args", "env")
194-
if (sum(idx) != 2) return(l)
194+
if (sum(idx) != 2) return(struct(l, "plotly"))
195195
nms <- names(l)
196196
# assume unnamed list elements are data/traces
197197
idx <- nms %in% ""
@@ -307,8 +307,7 @@ plotly_build <- function(l = get_plot()) {
307307
# traces shouldn't have any names
308308
x$data <- setNames(x$data, NULL)
309309
# add plotly class mainly for printing method
310-
class(x) <- unique(c("plotly", class(x)))
311-
x
310+
struct(x, "plotly")
312311
}
313312

314313
# returns a _list of traces_.

0 commit comments

Comments
 (0)