| Title: | Hierarchical Input Component for Shiny |
|---|---|
| Description: | Hierarchical slicer-style input for Shiny applications with multi-selection, tri-state checkboxes, search, cascading selection, and a structured selection value for analytics workflows. |
| Authors: | Luis Rodriguez [aut, cre] |
| Maintainer: | Luis Rodriguez <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-03 10:49:39 UTC |
| Source: | https://github.com/cran/shinyHierarchy |
Converts a data frame and an ordered set of columns into a nested hierarchy suitable for the Shiny input component.
buildHierarchyTree(data, levels)buildHierarchyTree(data, levels)
data |
A data frame containing the hierarchy columns. |
levels |
A character vector with column names, ordered from highest to lowest hierarchy level. |
A list representing the hierarchy tree.
data <- data.frame( year = c(2026, 2026, 2026), month = c("January", "January", "February"), day = c(1, 2, 1) ) buildHierarchyTree(data, c("year", "month", "day"))data <- data.frame( year = c(2026, 2026, 2026), month = c("January", "January", "February"), day = c(1, 2, 1) ) buildHierarchyTree(data, c("year", "month", "day"))
Creates a hierarchical slicer-style input similar to a Power BI date
hierarchy. The input value is a structured object (schema version 1) with
resolved, rollup, explicit, and summary fields.
hierarchyInput( inputId, label = NULL, data, levels, selected = NULL, expanded = NULL, placeholder = "Selección múltiple", display = c("inline", "dropdown"), search = FALSE, searchPlaceholder = "Buscar...", selectAll = TRUE, selectAllLabel = "Seleccionar todo", expand = c("first", "all", "none"), width = "100%", height = "360px" )hierarchyInput( inputId, label = NULL, data, levels, selected = NULL, expanded = NULL, placeholder = "Selección múltiple", display = c("inline", "dropdown"), search = FALSE, searchPlaceholder = "Buscar...", selectAll = TRUE, selectAllLabel = "Seleccionar todo", expand = c("first", "all", "none"), width = "100%", height = "360px" )
inputId |
The input slot that will be used to access the value. |
label |
Optional label displayed above the component. |
data |
A data frame containing the hierarchy columns. |
levels |
Character vector with column names, ordered from highest to lowest hierarchy level. |
selected |
Optional character vector of node ids to select initially. |
expanded |
Optional character vector of node ids to expand initially. |
placeholder |
Text shown when nothing is selected. |
display |
Visual presentation: |
search |
Whether to show a search box above the tree. |
searchPlaceholder |
Placeholder for the search field. |
selectAll |
Whether to show the select-all row. |
selectAllLabel |
Label for the select-all control. |
expand |
Initial expansion mode: first level, all levels, or none. |
width |
CSS width of the component. |
height |
CSS max-height of the tree area. |
The value received from the browser is user-controlled and must not be used as an authorization mechanism. Applications that filter sensitive data must validate selected ids against the server-side hierarchy and permissions.
A Shiny HTML object.
Extract path values at a given hierarchy level
hierarchyPath(value, level_name)hierarchyPath(value, level_name)
value |
Value returned by a hierarchy input ( |
level_name |
Name of the hierarchy level column. |
A character vector of unique values at that level among resolved selections.
Extract resolved leaf selections from a hierarchy input value
hierarchyResolved(value)hierarchyResolved(value)
value |
Value returned by a hierarchy input ( |
A list of resolved node records, or an empty list.
Extract rollup selections from a hierarchy input value
hierarchyRollup(value)hierarchyRollup(value)
value |
Value returned by a hierarchy input ( |
A list of rollup node records, or an empty list.
Update a hierarchical input from the server
updateHierarchyInput( session = shiny::getDefaultReactiveDomain(), inputId, data = NULL, levels = NULL, selected = NULL, expanded = NULL, clear = FALSE, open = NULL )updateHierarchyInput( session = shiny::getDefaultReactiveDomain(), inputId, data = NULL, levels = NULL, selected = NULL, expanded = NULL, clear = FALSE, open = NULL )
session |
Shiny session object. |
inputId |
The input id to update. |
data |
Optional new data frame. |
levels |
Optional hierarchy column names (required if |
selected |
Optional vector of node ids to select (cascades to descendants). |
expanded |
Optional vector of node ids to expand. |
clear |
If |
open |
If |
No useful return value, invisibly NULL.