Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# plotly (development version)

## Bug fixes

* Closed #1582, #2296: Avoid `hoveron=` related warnings when converting a ggplot object toWebGL().

# 4.10.3

## Improvements
Expand Down
13 changes: 13 additions & 0 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,24 @@ hide_legend <- function(p) {
toWebGL <- function(p) {
if (ggplot2::is.ggplot(p)) {
p <- plotly_build(p)
p <- remove_hoveron_from_gl_traces(p)
}
p$x$.plotlyWebGl <- TRUE
p
}

# ggplotly automatically assigns hoveron mappings that are incompatible with
# webGL based traces, we remove those mappings during toWebGL() conversion
# (See #1582)
remove_hoveron_from_gl_traces <- function(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))
}

#' Create a complete empty plotly graph.
#'
Expand Down