Skip to content

Commit 0826739

Browse files
committed
informative warning when using scattergl on Windows+RStudio, addresses #1214
1 parent 4dc1c15 commit 0826739

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

R/plotly_build.R

+4
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ plotly_build.plotly <- function(p, registerFrames = TRUE) {
395395
# if a partial bundle was specified, make sure it supports the visualization
396396
p <- verify_partial_bundle(p)
397397

398+
# scattergl currently doesn't render in RStudio on Windows
399+
# https://github.com/ropensci/plotly/issues/1214
400+
p <- verify_scattergl_platform(p)
401+
398402
# make sure plots don't get sent out of the network (for enterprise)
399403
p$x$base_url <- get_domain()
400404
p

R/utils.R

+16
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,22 @@ verify_guides <- function(p) {
830830
p
831831
}
832832

833+
verify_scattergl_platform <- function(p) {
834+
if (!identical(.Platform$OS.type, "windows")) return(p)
835+
if (!is_rstudio()) return(p)
836+
837+
types <- vapply(p, function(x) x[["type"]] %||% "scatter", character(1))
838+
if ("scattergl" %in% types) {
839+
warning(
840+
"'scattergl' trace types don't currently render in RStudio on Windows",
841+
"Open in another web browser (IE, Chrome, Firefox, etc).",
842+
call. = FALSE
843+
)
844+
}
845+
846+
p
847+
}
848+
833849
has_marker <- function(types, modes) {
834850
is_scatter <- grepl("scatter", types)
835851
ifelse(is_scatter, grepl("marker", modes), has_attr(types, "marker"))

0 commit comments

Comments
 (0)