Skip to content

Commit 1992179

Browse files
committed
Throw more informative warning if titlefont is detected and move from titlefont to title.font in ggplotly()
1 parent 36b4215 commit 1992179

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

R/ggplotly.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,11 @@ gg2list <- function(p, width = NULL, height = NULL,
429429
)
430430
# main plot title
431431
if (nchar(plot$labels$title %||% "") > 0) {
432-
gglayout$title <- faced(plot$labels$title, theme$plot.title$face)
433-
gglayout$titlefont <- text2font(theme$plot.title)
434-
gglayout$margin$t <- gglayout$margin$t + gglayout$titlefont$size
432+
gglayout$title <- list(
433+
text = faced(plot$labels$title, theme$plot.title$face),
434+
font = text2font(theme$plot.title)
435+
)
436+
gglayout$margin$t <- gglayout$margin$t + gglayout$title$font$size
435437
}
436438
# ensure there's enough space for the modebar (this is based on a height of 1em)
437439
# https://github.com/plotly/plotly.js/blob/dd1547/src/components/modebar/index.js#L171

R/utils.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,10 @@ verify_attr <- function(proposed, schema) {
516516

517517
attrs_name_check <- function(proposedAttrs, validAttrs, type = "scatter") {
518518
illegalAttrs <- setdiff(proposedAttrs, validAttrs)
519+
if ("titlefont" %in% illegalAttrs) {
520+
warning("The titlefont attribute is now deprecated. Use title = list(font = ...) instead.", call. = FALSE)
521+
illegalAttrs <- setdiff(illegalAttrs, "titlefont")
522+
}
519523
if (length(illegalAttrs)) {
520524
warning("'", type, "' objects don't have these attributes: '",
521525
paste(illegalAttrs, collapse = "', '"), "'\n",

0 commit comments

Comments
 (0)