updated build_grid method
This commit is contained in:
parent
2d9b9ff631
commit
f91a6c69c6
|
@ -294,8 +294,8 @@ build_facet_tag <- function(x) {
|
|||
content,
|
||||
nrow = facets$nrow %||% 1,
|
||||
ncol = facets$ncol %||% 1,
|
||||
row_label = if (!is.null(facets$ncol)) "30px" else NULL,
|
||||
col_label = if (!is.null(facets$nrow)) "30px" else NULL,
|
||||
row_before = if (!is.null(facets$ncol)) "30px",
|
||||
col_after = if (!is.null(facets$nrow)) "30px",
|
||||
row_gap = "3px",
|
||||
col_gap = "3px"
|
||||
)
|
||||
|
|
32
R/grid.R
32
R/grid.R
|
@ -24,38 +24,20 @@ build_grid <- function(content,
|
|||
ncol = NULL,
|
||||
row_gap = "5px",
|
||||
col_gap = "0px",
|
||||
row_label = NULL,
|
||||
col_label = NULL,
|
||||
row_before = NULL,
|
||||
row_after = NULL,
|
||||
col_before = NULL,
|
||||
col_after = NULL,
|
||||
height = NULL,
|
||||
width = NULL) {
|
||||
d <- get_grid_dims(content, nrow, ncol)
|
||||
if (is.null(col_label)) {
|
||||
col_style <- sprintf(
|
||||
"-ms-grid-columns: repeat(%1$s, 1fr); grid-template-columns: repeat(%1$s, 1fr);",
|
||||
d$ncol
|
||||
)
|
||||
} else {
|
||||
col_style <- sprintf(
|
||||
"-ms-grid-columns: repeat(%1$s, 1fr) %2$s; grid-template-columns: repeat(%1$s, 1fr) %2$s;",
|
||||
d$ncol, col_label
|
||||
)
|
||||
}
|
||||
if (is.null(row_label)) {
|
||||
row_style <- sprintf(
|
||||
"-ms-grid-rows: repeat(%1$s, 1fr); grid-template-rows: repeat(%1$s, 1fr);",
|
||||
d$nrow
|
||||
)
|
||||
} else {
|
||||
row_style <- sprintf(
|
||||
"-ms-grid-rows: %2$s repeat(%1$s, 1fr); grid-template-rows: %2$s repeat(%1$s, 1fr);",
|
||||
d$nrow, row_label
|
||||
)
|
||||
}
|
||||
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:-ms-grid; display: grid;",
|
||||
style = "display: grid;",
|
||||
style = col_style,
|
||||
style = row_style,
|
||||
style = sprintf("grid-column-gap: %s;", col_gap),
|
||||
|
|
Loading…
Reference in New Issue