Skip to content

Commit d9652a6

Browse files
authored
Avoid hoveron warning
When converting a ggplot object to webgl, invalid 'hoveron' warnings appear. If the toWebGL() function receives the ggplot object then it is possible for us to remove those warnings. Closes: #2296 Closes: #1582
1 parent 270d20e commit d9652a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

R/helpers.R

+7
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ hide_legend <- function(p) {
162162
toWebGL <- function(p) {
163163
if (ggplot2::is.ggplot(p)) {
164164
p <- plotly_build(p)
165+
traces_without_hoveron <- glTypes()
166+
trace_idx <- vapply(
167+
p$x$data,
168+
function(trace) trace$type %in% traces_without_hoveron,
169+
logical(1)
170+
)
171+
p <- style(p, hoveron = NULL, traces = which(trace_idx))
165172
}
166173
p$x$.plotlyWebGl <- TRUE
167174
p

0 commit comments

Comments
 (0)