Skip to content

Commit

Permalink
Add crosstalk mapping to computed_mapping (not mapping) when present (#…
Browse files Browse the repository at this point in the history
…1964)

* Follow up to #1952: add crosstalk mapping to computed_mapping (not mapping) when present

* use dev version; update news
  • Loading branch information
cpsievert authored Jun 17, 2021
1 parent 9fe33eb commit 771d584
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: plotly
Title: Create Interactive Web Graphics via 'plotly.js'
Version: 4.9.4
Version: 4.9.4.9000
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
email = "[email protected]", comment = c(ORCID = "0000-0002-4958-2844")),
person("Chris", "Parmer", role = "aut",
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# 4.9.4.9000

## BUG FIXES

* Fixes a bug in `ggplotly()` with `{crosstalk}` and `{ggplot2}` v3.3.4 (#1952).

# 4.9.4

## BUG FIXES

* Duplicate `highlight(selectize=T)` dropdowns are no longer rendered in Shiny (#1936).
* `group_by.plotly()` now properly retains crosstalk information across `{dplyr}` versions (#1920).
* Adds fixes in `ggplotly()` for the upcoming `{ggplot2}` >3.3.3 release (#1952).
* Adds fixes in `ggplotly()` for the upcoming `{ggplot2}` v3.3.4 release (#1952).
* Fixes some issues with `name` and `frames` when both attributes are specified. (#1903 and #1618).

# 4.9.3
Expand Down
7 changes: 6 additions & 1 deletion R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ gg2list <- function(p, width = NULL, height = NULL,
layers <- Map(function(x, y) {
if (crosstalk_key() %in% names(y) && !"key" %in% names(x[["mapping"]]) &&
inherits(x[["stat"]], "StatIdentity")) {
x[["mapping"]] <- c(x[["mapping"]], key = as.name(crosstalk_key()))
# ggplot2 v3.3.4 started using the computed_mapping (instead of mapping)
# field to inform the compute_aesthetics() method, so in order to add
# the crosstalk key, we need to add to that field (when present)
# https://github.com/tidyverse/ggplot2/pull/4475
nm <- if ("computed_mapping" %in% names(x)) "computed_mapping" else "mapping"
x[[nm]] <- c(x[[nm]], key = as.name(crosstalk_key()))
}
x
}, layers, layer_data)
Expand Down

0 comments on commit 771d584

Please sign in to comment.