Skip to content

Commit

Permalink
facet wrap: fixed grid area for xaxis title
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Jun 11, 2024
1 parent 5f8389f commit 9ebabd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions R/facets.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ build_facet_tag <- function(x) {
if (identical(facets$type, "wrap")) {
area <- paste(
d$nrow + 1,
1,
d$nrow + 1,
d$ncol + 2,
1 + !is.null(facets$yaxis_title$text) * 1,
d$nrow + 2,
d$ncol + 1 + !is.null(facets$yaxis_title$text) * 1,
sep = " / "
)
} else {
Expand Down
20 changes: 10 additions & 10 deletions R/grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ get_grid_dims <- function(content, nrow = NULL, ncol = NULL) {
}


#' @importFrom htmltools tags
#' @importFrom htmltools tags css
build_grid <- function(content,
nrow = NULL,
ncol = NULL,
Expand All @@ -31,17 +31,17 @@ build_grid <- function(content,
height = NULL,
width = NULL) {
d <- get_grid_dims(content, nrow, ncol)
col_style <- paste("grid-template-columns:", col_before, sprintf("repeat(%s, 1fr)", d$ncol), col_after, ";")
row_style <- paste("grid-template-rows:", row_before, sprintf("repeat(%s, 1fr)", d$nrow), row_after, ";")
tags$div(
class = "apexcharter-grid-container",
style = if (!is.null(height)) paste0("height:", height, ";"),
style = if (!is.null(width)) paste0("width:", width, ";"),
style = "display: grid;",
style = col_style,
style = row_style,
style = sprintf("grid-column-gap: %s;", col_gap),
style = sprintf("grid-row-gap: %s;", row_gap),
style = css(
height = height,
width = width,
display = "grid",
gridTemplateColumns = paste(col_before, sprintf("repeat(%s, 1fr)", d$ncol), col_after),
gridTemplateRows = paste(row_before, sprintf("repeat(%s, 1fr)", d$nrow), row_after),
gridColumnGap = col_gap,
gridRowGap = row_gap
),
content
)
}
Expand Down

0 comments on commit 9ebabd7

Please sign in to comment.