Skip to content

Commit

Permalink
updated custom headers tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Mar 18, 2024
1 parent c36cab7 commit bba3ed7
Showing 1 changed file with 96 additions and 4 deletions.
100 changes: 96 additions & 4 deletions examples/zzz-grid-custom-header.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,81 @@ datagrid(mtcars, theme = "striped", colwidths = "guess") %>%
)



datagrid(ps3_games[, c(1, 5, 6, 7, 8)], colwidths = "guess", theme = "striped") %>%
library(toastui)
library(htmltools)
# set_grid_theme(cell.summary.background = "#E6E7E7", cell.summary.showHorizontalBorder = TRUE)
datagrid(ps3_games[, c(1, 3, 5, 6, 7, 8)], colwidths = "guess", theme = "striped") %>%
grid_summary(
column = "Name",
js_function = JS(
"function(value) {",
# "return \"<span style='font-style: italic;'>character</span>\";",
sprintf("return '%s<span style=\"font-style: italic; margin-left: 5px;\">character</span>';", gsub("\n", "", htmltools::doRenderTags(phosphoricons::ph("text-aa")))),
sprintf(
"return '%s';",
gsub(replacement = "", pattern = "\n", x = htmltools::doRenderTags(
tags$div(
style = css(padding = "5px 0"),
tags$div(
style = css(fontStyle = "italic"),
phosphoricons::ph("text-aa"),
"character"
),
tags$hr(),
tags$div(
"Unique:", length(unique(ps3_games$Name))
),
tags$div(
"Missing:", sum(is.na(ps3_games$Name))
),
tags$div(
style = css(whiteSpace = "normal", wordBreak = "break-all"),
"Most Common:", gsub(
pattern = "'",
replacement = "\u07F4",
x = names(sort(table(ps3_games$Name), decreasing = TRUE))[1]
)
),
tags$div(
"\u00A0"
)
)
))
),
"}"
),
position = "top"
) %>%
grid_summary(
column = "Genre",
js_function = JS(
"function(value) {",
# "return \"<span style='font-style: italic;'>character</span>\";",
sprintf(
"return '%s';",
gsub(replacement = "", pattern = "\n", x = htmltools::doRenderTags(
tags$div(
style = css(padding = "5px 0"),
tags$div(
style = css(fontStyle = "italic"),
phosphoricons::ph("text-aa"),
"character"
),
tags$hr(),
tags$div(
"Unique:", length(unique(ps3_games$Genre))
),
tags$div(
"Missing:", sum(is.na(ps3_games$Genre))
),
tags$div(
"Most Common:", names(sort(table(ps3_games$Genre), decreasing = TRUE))[1]
),
tags$div(
"\u00A0"
)
)
))
),
"}"
),
position = "top"
Expand All @@ -73,7 +140,32 @@ datagrid(ps3_games[, c(1, 5, 6, 7, 8)], colwidths = "guess", theme = "striped")
column = "NA_Sales",
js_function = JS(
"function(value) {",
sprintf("return '%s<span style=\"font-style: italic; margin-left: 5px;\">numeric</span>';", gsub("\n", "", htmltools::doRenderTags(phosphoricons::ph("hash")))),
sprintf(
"return '%s';",
gsub(replacement = "", pattern = "\n", x = htmltools::doRenderTags(
tags$div(
style = css(padding = "5px 0"),
tags$div(
style = css(fontStyle = "italic"),
phosphoricons::ph("hash"),
"numeric"
),
tags$hr(),
tags$div(
"Min:", min(ps3_games$NA_Sales, na.rm = TRUE)
),
tags$div(
"Mean:", mean(ps3_games$NA_Sales, na.rm = TRUE)
),
tags$div(
"Max:", max(ps3_games$NA_Sales, na.rm = TRUE)
),
tags$div(
"Missing:", sum(is.na(ps3_games$NA_Sales))
)
)
))
),
"}"
),
position = "top"
Expand Down

0 comments on commit bba3ed7

Please sign in to comment.