grid-cell-style {toastui} | R Documentation |
Set grid cell(s) style
Description
Customize cell(s) appearance with CSS according to an expression in the data used in the grid.
Usage
grid_style_cell(
grid,
expr,
column,
background = NULL,
color = NULL,
fontWeight = NULL,
...,
class = NULL,
cssProperties = NULL
)
grid_style_cells(
grid,
fun,
columns,
background = NULL,
color = NULL,
...,
class = NULL,
cssProperties = NULL
)
Arguments
grid |
A grid created with |
expr |
An expression giving position of row. Must return a logical vector. |
column |
Name of column (variable name) where to apply style. |
background |
Background color. |
color |
Text color. |
fontWeight |
Font weight, you can use |
... |
Other CSS properties. |
class |
CSS class to apply to the row. |
cssProperties |
Alternative to specify CSS properties with a named list. |
fun |
Function to apply to |
columns |
Columns names to use with |
Value
A datagrid
htmlwidget.
Examples
library(toastui)
datagrid(mtcars) %>%
grid_style_cell(
mpg > 19,
column = "mpg",
background = "#F781BE",
fontWeight = "bold"
)
datagrid(mtcars) %>%
grid_style_cell(
vs == 0,
column = "vs",
background = "#E41A1C80",
color = "#FFF"
) %>%
grid_style_cell(
vs == 1,
column = "vs",
background = "#377EB880"
)
# Use rlang to use character
library(rlang)
my_var <- "disp"
datagrid(mtcars) %>%
grid_style_cell(
!!sym(my_var) > 180,
column = "disp",
background = "#F781BE"
)
# Style multiple columns
cor_longley <- as.data.frame(cor(longley))
cor_longley$Var <- row.names(cor_longley)
vars <- c("GNP.deflator", "GNP",
"Unemployed", "Armed.Forces",
"Population", "Year", "Employed")
datagrid(cor_longley[, c("Var", vars)]) %>%
grid_style_cells(
fun = ~ . > 0.9,
columns = vars,
background = "#053061",
color = "#FFF"
) %>%
grid_style_cells(
fun = ~ . > 0 & . <= 0.9,
columns = vars,
background = "#539dc8",
color = "#FFF"
) %>%
grid_style_cells(
fun = ~ . < 0,
columns = vars,
background = "#b51f2e",
color = "#FFF"
)
[Package toastui version 0.3.3 Index]