Skip to content

Commit a7f09db

Browse files
committed
Translate custom facet labeller functions. Fixes #507
1 parent ae20cba commit a7f09db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/ggplotly.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
303303
rep(panelMarginX, 2),
304304
rep(panelMarginY, 2)
305305
)
306+
306307
doms <- get_domains(nPanels, nRows, margins)
307308

308309
for (i in seq_len(nPanels)) {
@@ -428,12 +429,11 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
428429
gglayout$shapes <- c(gglayout$shapes, border)
429430

430431
# facet strips -> plotly annotations
431-
# TODO: use p$facet$labeller for the actual strip text!
432432
if (!is_blank(theme[["strip.text.x"]]) &&
433433
(inherits(p$facet, "wrap") || inherits(p$facet, "grid") && lay$ROW == 1)) {
434434
vars <- ifelse(inherits(p$facet, "wrap"), "facets", "cols")
435435
txt <- paste(
436-
lay[, as.character(p$facet[[vars]])], collapse = ", "
436+
p$facet$labeller(lay[names(p$facet[[vars]])]), collapse = ", "
437437
)
438438
lab <- make_label(
439439
txt, x = mean(xdom), y = max(ydom),
@@ -447,7 +447,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
447447
if (inherits(p$facet, "grid") && lay$COL == nCols && nRows > 1 &&
448448
!is_blank(theme[["strip.text.y"]])) {
449449
txt <- paste(
450-
lay[, as.character(p$facet$rows)], collapse = ", "
450+
p$facet$labeller(lay[names(p$facet$rows)]), collapse = ", "
451451
)
452452
lab <- make_label(
453453
txt, x = max(xdom), y = mean(ydom),

0 commit comments

Comments
 (0)