Skip to content

Commit bab8da4

Browse files
committed
restrict candidates for hoverinfo from stat's default_aes
1 parent 84c3e78 commit bab8da4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

R/ggplotly.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ gg2list <- function(p, width = NULL, height = NULL, mapping = "all", source = "A
185185
# layer level mappings
186186
as.character(x$mapping),
187187
# stat specific mappings
188-
as.character(x$stat$default_aes)
188+
grep("^\\.\\.", as.character(x$stat$default_aes), value = TRUE)
189189
)
190190
# remove leading/trailing dots in "hidden" stat aes
191191
map <- sub("^\\.\\.", "", sub("\\.\\.$", "", map))
@@ -206,6 +206,7 @@ gg2list <- function(p, width = NULL, height = NULL, mapping = "all", source = "A
206206
# attach a new column (hovertext) to each layer of data that should get mapped
207207
# to the text trace property
208208
data <- Map(function(x, y) {
209+
# make sure the relevant aes exists in the data
209210
for (i in seq_along(y)) {
210211
aesName <- names(y)[[i]]
211212
# TODO: should we be getting the name from scale_*(name) first?

0 commit comments

Comments
 (0)