Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Sep 13, 2024
1 parent da6cad8 commit 51fbec0
Show file tree
Hide file tree
Showing 26 changed files with 140 additions and 38 deletions.
8 changes: 6 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
Package: rtabulator
Type: Package
Title: R Bindings for Tabulator JS
Version: 0.1.0
Date: 2024-09-08
Version: 0.1.1
Date: 2024-09-13
Authors@R: c(
person("Stefan", "Kuethe", email = "[email protected]", role = c("aut", "cre")),
person("Nico", "Friess", email = "[email protected]", role = c("aut"))
)
Maintainer: Stefan Kuethe <[email protected]>
Description: Provides R bindings for 'Tabulator JS' <https://tabulator.info/>.
Makes it a breeze to create beautiful interactive tables.
URL:
https://github.com/eodaGmbH/rtabulator
https://eodagmbh.github.io/rtabulator/
BugReports: https://github.com/eodaGmbH/rtabulator/issues
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# rtabulator 0.1.1

* Update docs
* Add pkgdown site
* Add function to create multi column headers
* Add a lot of examples
* Update README
* Make `devtools::check()` pass 🚀

# rtabulator 0.1.0

* Add NEWS.md to track changes.
10 changes: 5 additions & 5 deletions R/columns.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Create columns definition from data
#' Create column definitions from data
#' @param data (data.frame) data
#' @param editor (bool): Whether to make columns editable.
#' @param filter (bool): Whether to add a header filter to the columns.
Expand Down Expand Up @@ -313,8 +313,7 @@ set_formatter_datetime <- function(
input_format = "yyyy-MM-dd hh:ss:mm",
output_format = "yy/MM/dd",
invalid_placeholder = "(invalid datetime)",
timezone = NA
) {
timezone = NA) {
# Body
col_update <- list(
formatter = "datetime",
Expand All @@ -339,6 +338,7 @@ set_formatter_color <- function(widget, column) {

#' Traffic Light Formatter
#' @inheritParams set_formatter_progress
#' @example examples/formatters/formatter_traffic_light.R
#' @export
set_formatter_traffic_light <- function(
widget,
Expand All @@ -348,9 +348,9 @@ set_formatter_traffic_light <- function(
color = c("green", "orange", "red"),
hoz_align = "center") {
# Body
if (is.na(min)) min = min(widget$x$data[column])
if (is.na(min)) min <- min(widget$x$data[column])

if (is.na(max)) max = max(widget$x$data[column])
if (is.na(max)) max <- max(widget$x$data[column])

col_update <- list(
formatter = "traffic",
Expand Down
1 change: 1 addition & 0 deletions R/tabulator.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' @param height Height of the widget.
#' @param element_id The unique ID of the widget.
#' @param ... Named arguments that are appended to the \code{options} parameter.
#' @example examples/multiple_spreadsheets.R
#' @import htmlwidgets
#' @export
tabulator <- function(
Expand Down
3 changes: 2 additions & 1 deletion R/tabulator_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ invoke_method <- function(widget, method_name, ...) {
invisible(widget)
}

#' Create a Tabulator Context
#' Create a Tabulator Context Object
#' A \code{tabulatorContext} object makes it possible to update your widget in a Shiny app.
#' @param output_id (character): A tabulator output id.
#' @param session shiny session object
#' @export
Expand Down
1 change: 1 addition & 0 deletions R/tabulator_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#' @param spreadsheet_sheet_tabs (bool): Whether to show sheet tabs in the footer.
#' @param ... Further options.
#' @seealso \url{https://tabulator.info/docs/6.2/options}
#' @example examples/tabulator_setup.R
#' @export
tabulator_options <- function(
# General
Expand Down
36 changes: 36 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,39 @@ url: ~
template:
bootstrap: 5

reference:
- title: Tabulator Widget
desc: >
Functions to create and setup a Tabulator widget
contents:
- tabulator
- tabulator_options
- set_column_editor
- set_header_filter
- set_multi_column_header

- title: Column Formatters
desc: >
Functions to set column formatters
contents:
- starts_with("set_formatter")

- title: Shiny Integration
contents:
- rtabulator-shiny
- tabulatorContext
- add_row
- delete_selected_rows
- trigger_download
- trigger_get_data
- trigger_get_spreadsheet_data
- undo
- redo

- title: Utils
desc: >
Utitily functions
contents:
- list_to_data_frame
- create_columns

2 changes: 1 addition & 1 deletion examples/formatters/formatter_datetime.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
data <- data.frame(
Person = c("Franz", "Ferdinand"),
Birthday =c(
Birthday = c(
"2024-12-06 22:00:10",
"2023-06-07 14:12:45"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/formatters/formatter_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ data <- data.frame(
)
)

tabulator(data, width=200) |>
tabulator(data, width = 400) |>
set_formatter_html("text_style")
14 changes: 7 additions & 7 deletions examples/formatters/formatter_money.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
data <- data.frame(
Account_Number= c(
123456,
345667,
234567,
234566
),
Account_Number = c(
123456,
345667,
234567,
234566
),
Account_Balance = c(100, -50, 200.30, -21.5)
)

tabulator(data, width = 300) |>
tabulator(data) |>
set_formatter_money(
"Account_Balance",
symbol = "\U20AC",
Expand Down
2 changes: 1 addition & 1 deletion examples/formatters/formatter_progress.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data <- data.frame(

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

tabulator(data, width = 300) |>
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")
2 changes: 1 addition & 1 deletion examples/formatters/formatter_textarea.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ data <- data.frame(
txt = c(
"This\nis\nsome\ntext\nwith\nmultiple\nline\nbreaks",
"- R\n- Python\n- Julia"
)
)
)

tabulator(data, width = 200) |>
Expand Down
2 changes: 1 addition & 1 deletion examples/formatters/formatter_tick_cross.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data <- data.frame(
Artist = c("Art Blackey", "Nirvana", "Bob Marley"),
Grunge = c(0, 1, 0),
Jazz = c(1, 0, 0),
Reggae = c(0,0,1)
Reggae = c(0, 0, 1)
)

tabulator(data, width = 400) |>
Expand Down
4 changes: 2 additions & 2 deletions examples/multiple_spreadsheets.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
options <- tabulator_options(
setup <- tabulator_options(
spreadsheet = TRUE,
spreadsheet_sheets = list(
list(
Expand All @@ -13,4 +13,4 @@ options <- tabulator_options(
spreadsheet_sheet_tabs = TRUE
)

tabulator(data = NULL, options, theme = "midnight")
tabulator(data = NULL, setup, theme = "midnight")
9 changes: 9 additions & 0 deletions examples/tabulator_setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
setup <- tabulator_options(
group_by = "Species",
pagination = TRUE,
pagination_size = 10,
pagination_size_selector = c(10, 20, 50),
movable_columns = TRUE,
movable_rows = TRUE
)
tabulator(iris, setup)
4 changes: 2 additions & 2 deletions man/create_columns.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/set_formatter_datetime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/set_formatter_html.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/set_formatter_money.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/set_formatter_progress.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/set_formatter_textarea.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/set_formatter_tick_cross.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions man/set_formatter_traffic_light.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/tabulator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/tabulatorContext.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/tabulator_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51fbec0

Please sign in to comment.