Skip to content

Commit 669db9c

Browse files
authored
Merge pull request #1650 from ropensci/ggplotly-calculated-tooltip
Ignore calculated aesthetics that match specified aesthestics
2 parents 9bcf90a + 27db11e commit 669db9c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

R/layers2traces.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ layers2traces <- function(data, prestats_data, layout, p) {
1010
position = ggtype(y, "position")
1111
)
1212

13+
# add on plot-level mappings, if they're inherited
14+
map <- c(y$mapping, if (isTRUE(y$inherit.aes)) p$mapping)
15+
1316
# consider "calculated" aesthetics (e.g., density, count, etc)
1417
calc_aes <- y$stat$default_aes[ggfun("is_calculated_aes")(y$stat$default_aes)]
15-
map <- c(y$mapping, calc_aes)
18+
calc_aes <- calc_aes[!names(calc_aes) %in% names(map)]
1619

17-
# add on plot-level mappings, if they're inherited
18-
if (isTRUE(y$inherit.aes)) map <- c(map, p$mapping)
20+
map <- c(calc_aes, map)
1921

2022
# turn symbol (e.g., ..count..) & call (e.g. calc(count)) mappings into text labels
2123
map <- ggfun("make_labels")(map)

0 commit comments

Comments
 (0)