Skip to content

Commit f900837

Browse files
committed
track x/y domain before scale transformation; fixes #804
1 parent 3865540 commit f900837

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

R/ggplotly.R

+6-7
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ gg2list <- function(p, width = NULL, height = NULL,
283283
}, error = function(e) NULL
284284
)
285285
}, data, groupDomains)
286+
287+
# Before mapping x/y position, save the domain (for discrete scales)
288+
# to display in tooltip.
289+
data <- lapply(data, function(d) {
290+
dplyr::mutate(d, x_plotlyDomain = x, y_plotlyDomain = y)
291+
})
286292

287293
# Transform all scales
288294
data <- lapply(data, ggfun("scales_transform_df"), scales = scales)
@@ -294,13 +300,6 @@ gg2list <- function(p, width = NULL, height = NULL,
294300

295301
layout$train_position(data, scale_x(), scale_y())
296302

297-
# Before mapping x/y position, save the domain (for discrete scales)
298-
# to display in tooltip.
299-
data <- lapply(data, function(d) {
300-
if (!is.null(scale_x()) && scale_x()$is_discrete()) d$x_plotlyDomain <- d$x
301-
if (!is.null(scale_y()) && scale_y()$is_discrete()) d$y_plotlyDomain <- d$y
302-
d
303-
})
304303
data <- layout$map_position(data)
305304

306305
# build a mapping between group and key

0 commit comments

Comments
 (0)