Skip to content

Commit 684c779

Browse files
authored
Merge pull request #1635 from ropensci/verify-webgl
verify_webgl() shouldn't warn about types that are already gl
2 parents f8af657 + 6d90509 commit 684c779

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

R/utils.R

+5-4
Original file line numberDiff line numberDiff line change
@@ -823,14 +823,15 @@ verify_webgl <- function(p) {
823823
return(p)
824824
}
825825
types <- sapply(p$x$data, function(x) x[["type"]][1] %||% "scatter")
826-
idx <- paste0(types, "gl") %in% names(Schema$traces)
827-
if (any(!idx)) {
826+
can_gl <- paste0(types, "gl") %in% names(Schema$traces)
827+
already_gl <- grepl("gl$", types)
828+
if (any(!can_gl & !already_gl)) {
828829
warning(
829830
"The following traces don't have a WebGL equivalent: ",
830-
paste(which(!idx), collapse = ", ")
831+
paste(which(!can_gl & !already_gl), collapse = ", ")
831832
)
832833
}
833-
for (i in which(idx)) {
834+
for (i in which(can_gl)) {
834835
p$x$data[[i]]$type <- paste0(p$x$data[[i]]$type, "gl")
835836
}
836837
p

tests/testthat/test-plotly.R

+7
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,10 @@ test_that("Informative deprecation message for titlefont", {
310310
p <- layout(plot_ly(), title = "A title", titlefont = list(size = 30))
311311
expect_warning(plotly_build(p), "titlefont")
312312
})
313+
314+
test_that("toWebGL() shouldn't complain if it's already webgl", {
315+
p <- plot_ly(x = 1, y = 1) %>%
316+
add_trace(type = "scattergl", mode = "markers") %>%
317+
toWebGL()
318+
expect_silent(plotly_build(p))
319+
})

0 commit comments

Comments
 (0)