Skip to contents

Set progress formatter

Usage

set_formatter_progress(
  widget,
  columns,
  min = NA,
  max = NA,
  color = c("yellow", "orange", "red"),
  legend = NA,
  legend_color = "#000000",
  legend_align = c("center", "left", "right", "justify"),
  hoz_align = "left"
)

Arguments

widget

A tabulator() HTML widget.

columns

The names of the columns the formatter is applied to.

min

(numeric): The minimum value for progress bar. If set to NA, the minimum value of the column is used.

max

(numeric): The maximum value for progress bar. If set to NA, the maximum value of the column is used.

color

(character): Either a single color or a vector of colors

legend

(character, TRUE, JavaScript function): If set to TRUE, the value of the cell is displayed. Set to NA to display no value at all. Use JS to pass a JavaScript function as legend. In this case, the cell value is passed to the function as its first argument.

legend_color

(character): The text color of the legend.

legend_align

(character): The text alignment of the legend.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

data <- data.frame(
  id = 1:6,
  value = c(10, 0, 100, 20, 40, 60),
  value2 = c(10, 0, 100, 20, 40, 60),
  value3 = c(10, 0, 100, 20, 40, 60)
)

js_func <- htmlwidgets::JS("(cellValue) => `${cellValue}%`")

tabulator(data) |>
  set_formatter_progress("value") |>
  set_formatter_progress("value2", legend = TRUE, legend_align = "left") |>
  set_formatter_progress("value3", legend = js_func, legend_align = "right")