From d9652a6f55d6969037a18983dd10d59a8b225886 Mon Sep 17 00:00:00 2001 From: Sergio Oller Date: Fri, 6 Oct 2023 04:13:18 +0200 Subject: [PATCH] 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 --- R/helpers.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/helpers.R b/R/helpers.R index 8018ce0db9..2b7a80f3de 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -162,6 +162,13 @@ hide_legend <- function(p) { toWebGL <- function(p) { if (ggplot2::is.ggplot(p)) { p <- plotly_build(p) + traces_without_hoveron <- glTypes() + trace_idx <- vapply( + p$x$data, + function(trace) trace$type %in% traces_without_hoveron, + logical(1) + ) + p <- style(p, hoveron = NULL, traces = which(trace_idx)) } p$x$.plotlyWebGl <- TRUE p