-
Notifications
You must be signed in to change notification settings - Fork 633
Bug fix. Account for multi_line=FALSE when facet rows/cols are missing. Closes #2341. #2373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -917,11 +917,15 @@ gg2list <- function(p, width = NULL, height = NULL, | |
# facet strips -> plotly annotations | ||
if (has_facet(plot)) { | ||
col_vars <- ifelse(inherits(plot$facet, "FacetWrap"), "facets", "cols") | ||
col_txt <- paste( | ||
plot$facet$params$labeller( | ||
lay[names(plot$facet$params[[col_vars]])] | ||
), collapse = br() | ||
) | ||
col_txt <- if (!length(names(plot$facet$params[[col_vars]])) == 0) { | ||
paste( | ||
plot$facet$params$labeller( | ||
lay[names(plot$facet$params[[col_vars]])] | ||
), collapse = br() | ||
) | ||
} else { | ||
"" | ||
} | ||
if (is_blank(theme[["strip.text.x"]])) col_txt <- "" | ||
if (inherits(plot$facet, "FacetGrid") && lay$ROW != 1) col_txt <- "" | ||
if (robust_nchar(col_txt) > 0) { | ||
|
@@ -934,22 +938,30 @@ gg2list <- function(p, width = NULL, height = NULL, | |
strip <- make_strip_rect(xdom, ydom, theme, "top") | ||
gglayout$shapes <- c(gglayout$shapes, strip) | ||
} | ||
row_txt <- paste( | ||
plot$facet$params$labeller( | ||
lay[names(plot$facet$params$rows)] | ||
), collapse = br() | ||
) | ||
if (is_blank(theme[["strip.text.y"]])) row_txt <- "" | ||
if (inherits(plot$facet, "FacetGrid") && lay$COL != nCols) row_txt <- "" | ||
if (robust_nchar(row_txt) > 0) { | ||
row_lab <- make_label( | ||
row_txt, x = max(xdom), y = mean(ydom), | ||
el = theme[["strip.text.y"]] %||% theme[["strip.text"]], | ||
xanchor = "left", yanchor = "middle" | ||
) | ||
gglayout$annotations <- c(gglayout$annotations, row_lab) | ||
strip <- make_strip_rect(xdom, ydom, theme, "right") | ||
gglayout$shapes <- c(gglayout$shapes, strip) | ||
# Only FacetGrid has no cols | ||
if (inherits(plot$facet, "FacetGrid")) { | ||
row_txt <- if (!length(names(plot$facet$params$rows)) == 0) { | ||
paste( | ||
plot$facet$params$labeller( | ||
lay[names(plot$facet$params$rows)] | ||
), | ||
collapse = br() | ||
) | ||
} else { | ||
"" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar recommendation as https://github.com/plotly/plotly.R/pull/2373/files#r1742335996 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx for the review and the suggestions. Just committed both suggestions. |
||
if (is_blank(theme[["strip.text.y"]])) row_txt <- "" | ||
if (lay$COL != nCols) row_txt <- "" | ||
if (robust_nchar(row_txt) > 0) { | ||
row_lab <- make_label( | ||
row_txt, x = max(xdom), y = mean(ydom), | ||
el = theme[["strip.text.y"]] %||% theme[["strip.text"]], | ||
xanchor = "left", yanchor = "middle" | ||
) | ||
gglayout$annotations <- c(gglayout$annotations, row_lab) | ||
strip <- make_strip_rect(xdom, ydom, theme, "right") | ||
gglayout$shapes <- c(gglayout$shapes, strip) | ||
} | ||
} | ||
} | ||
} # end of panel loop | ||
|
Uh oh!
There was an error while loading. Please reload this page.