Skip to content

Commit

Permalink
Avoid hoveron warning
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zeehio authored Oct 6, 2023
1 parent 270d20e commit d9652a6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9652a6

Please sign in to comment.