Skip to content

Commit 64f9170

Browse files
committed
translate titlefont
1 parent c2fa0a1 commit 64f9170

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

R/ggplotly.R

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
353353
ticklen = unitConvert(theme$axis.ticks.length, "pixels", type),
354354
tickwidth = unitConvert(axisTicks, "pixels", type),
355355
showticklabels = !is_blank(axisText),
356-
tickfont = text2font(axisText, "height"),
356+
tickfont = text2font(axisText, type),
357357
tickangle = - (axisText$angle %||% 0),
358358
showline = !is_blank(axisLine),
359359
linecolor = toRGB(axisLine$colour),
@@ -364,9 +364,8 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
364364
gridwidth = unitConvert(panelGrid, "pixels", type),
365365
zeroline = FALSE,
366366
anchor = anchor,
367-
# if not facets then use Plotly axis titling mechanism
368-
# see https://github.com/ropensci/plotly/issues/510
369-
title = axisTitleText
367+
title = axisTitleText,
368+
titlefont = text2font(axisTitle)
370369
)
371370
# convert dates to milliseconds (86400000 = 24 * 60 * 60 * 1000)
372371
# this way both dates/datetimes are on same scale
@@ -413,8 +412,9 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
413412
if (xy == "y" && inherits(p$facet, "grid")) {
414413
gglayout$margin$r <- gglayout$margin$r + stripSize
415414
}
416-
# draw axis titles as annotations
417-
# (plotly.js axis titles aren't smart enough to dodge ticks & text)
415+
# facets have multiple axis objects, but only one title for the plot,
416+
# so we empty the titles and try to draw the title as an annotation
417+
gglayout[[axisName]]$title <- ""
418418
if (nchar(axisTitleText) > 0) {
419419
# npc is on a 0-1 scale of the _entire_ device,
420420
# but these units _should_ be wrt to the plotting region
@@ -432,13 +432,6 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
432432
}
433433
}
434434
}
435-
436-
if (has_facet(p)) {
437-
# turn off plotly axis titles
438-
# since we need special treatment for facets
439-
gglayout[[axisName]]$title <- ""
440-
}
441-
442435
} # end of axis loop
443436

444437
xdom <- gglayout[[lay[, "xaxis"]]]$domain

0 commit comments

Comments
 (0)