Skip to content

Commit a965714

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

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
@@ -294,6 +294,12 @@ gg2list <- function(p, width = NULL, height = NULL,
294294
}, error = function(e) NULL
295295
)
296296
}, data, groupDomains)
297+
298+
# Before mapping x/y position, save the domain (for discrete scales)
299+
# to display in tooltip.
300+
data <- lapply(data, function(d) {
301+
dplyr::mutate(d, x_plotlyDomain = x, y_plotlyDomain = y)
302+
})
297303

298304
# Transform all scales
299305
data <- lapply(data, ggfun("scales_transform_df"), scales = scales)
@@ -305,13 +311,6 @@ gg2list <- function(p, width = NULL, height = NULL,
305311

306312
layout$train_position(data, scale_x(), scale_y())
307313

308-
# Before mapping x/y position, save the domain (for discrete scales)
309-
# to display in tooltip.
310-
data <- lapply(data, function(d) {
311-
if (!is.null(scale_x()) && scale_x()$is_discrete()) d$x_plotlyDomain <- d$x
312-
if (!is.null(scale_y()) && scale_y()$is_discrete()) d$y_plotlyDomain <- d$y
313-
d
314-
})
315314
data <- layout$map_position(data)
316315

317316
# build a mapping between group and key

0 commit comments

Comments
 (0)