grid_colorbar {toastui}R Documentation

Style cells with a color bar

Description

Style cells with a color bar

Usage

grid_colorbar(
  grid,
  column,
  bar_bg = "#5E81AC",
  color = "#ECEFF4",
  background = "#ECEFF4",
  from = NULL,
  prefix = NULL,
  suffix = NULL,
  label_outside = FALSE,
  label_width = "20px",
  border_radius = "0px",
  height = "16px",
  align = c("left", "center", "right")
)

Arguments

grid

A grid created with datagrid().

column

The name of the column where to create a color bar.

bar_bg

Background color of the color bar.

color

Color of the text.

background

Background of the cell.

from

Range of values of the variable to represent as a color bar.

prefix, suffix

String to put in front of or after the value.

label_outside

Show label outside of the color bar.

label_width

Width of label in case it's displayed outside the color bar.

border_radius

Border radius of color bar.

height

Height in pixel of color bar.

align

Alignment of label if it is displayed inside the color bar.

Value

A datagrid htmlwidget.

Examples

library(toastui)

dat <- rolling_stones_50[, "Artist", drop = FALSE]
dat$percentage <- sample(1:100, size = 50, replace = TRUE)
dat$numeric <- sample(1:1500, size = 50, replace = TRUE)

datagrid(dat) %>%
  grid_colorbar(
    column = "percentage"
  )

datagrid(dat) %>%
  grid_colorbar(
    column = "percentage",
    label_outside = TRUE
  )

# More options
datagrid(dat) %>%
  grid_colorbar(
    column = "percentage",
    from = c(0, 100),
    suffix = "%"
  ) %>%
  grid_colorbar(
    column = "numeric",
    bar_bg = "#BF616A",
    from = c(0, 1500),
    prefix = "$",
    height = "20px"
  )


data.frame(
  rn = rownames(mtcars),
  mpg = mtcars$mpg,
  check.names = FALSE
) %>%
  datagrid(colnames = c("Automobile", "Miles/(US) gallon")) %>%
  grid_colorbar(
    column = "mpg",
    bar_bg = ifelse(mtcars$mpg > mean(mtcars$mpg), "#5cb85c", "#BF616A"),
    label_outside = TRUE,
    label_width = "25px"
  )


[Package toastui version 0.3.3 Index]