Skip to content

Commit

Permalink
verify_webgl() shouldn't warn about types that are already gl, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Oct 8, 2019
1 parent 6ecca60 commit dcd4219
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,15 @@ verify_webgl <- function(p) {
return(p)
}
types <- sapply(p$x$data, function(x) x[["type"]][1] %||% "scatter")
idx <- paste0(types, "gl") %in% names(Schema$traces)
if (any(!idx)) {
can_gl <- paste0(types, "gl") %in% names(Schema$traces)
already_gl <- grepl("gl$", types)
if (any(!can_gl & !already_gl)) {
warning(
"The following traces don't have a WebGL equivalent: ",
paste(which(!idx), collapse = ", ")
paste(which(!can_gl & !already_gl), collapse = ", ")
)
}
for (i in which(idx)) {
for (i in which(can_gl)) {
p$x$data[[i]]$type <- paste0(p$x$data[[i]]$type, "gl")
}
p
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,10 @@ test_that("Informative deprecation message for titlefont", {
p <- layout(plot_ly(), title = "A title", titlefont = list(size = 30))
expect_warning(plotly_build(p), "titlefont")
})

test_that("toWebGL() shouldn't complain if it's already webgl", {
p <- plot_ly(x = 1, y = 1) %>%
add_markers() %>%
toWebGL()
expect_silent(plotly_build(p))
})

0 comments on commit dcd4219

Please sign in to comment.