FilterPanelAPI | R Documentation |
An API class for managing filter states in a teal application's filter panel.
The purpose of this class is to encapsulate the API of the filter panel in a
new class FilterPanelAPI
so that it can be passed and used in the server
call of any module instead of passing the whole FilteredData
object.
This class is supported by methods to set, get, remove filter states in the filter panel API.
new()
Initialize a FilterPanelAPI
object.
FilterPanelAPI$new(datasets)
datasets
(FilteredData
)
get_filter_state()
Gets the reactive values from the active FilterState
objects of the FilteredData
object.
Gets all active filters in the form of a nested list.
The output list is a compatible input to set_filter_state
.
FilterPanelAPI$get_filter_state()
list
with named elements corresponding to FilteredDataset
objects with active filters.
set_filter_state()
Sets active filter states.
FilterPanelAPI$set_filter_state(filter)
filter
(teal_slices
)
NULL
, invisibly.
remove_filter_state()
Remove one or more FilterState
of a FilteredDataset
in the FilteredData
object.
FilterPanelAPI$remove_filter_state(filter)
filter
(teal_slices
)
specifying FilterState
objects to remove;
teal_slice
s may contain only dataname
and varname
, other elements are ignored
NULL
, invisibly.
clear_filter_states()
Remove all FilterStates
of the FilteredData
object.
FilterPanelAPI$clear_filter_states(datanames)
datanames
(character
)
datanames
to remove their FilterStates
;
omit to remove all FilterStates
in the FilteredData
object
NULL
, invisibly.
clone()
The objects of this class are cloneable with this method.
FilterPanelAPI$clone(deep = FALSE)
deep
Whether to make a deep clone.
library(shiny)
fd <- init_filtered_data(list(iris = iris))
fpa <- FilterPanelAPI$new(fd)
# get the actual filter state --> empty named list
isolate(fpa$get_filter_state())
# set a filter state
set_filter_state(
fpa,
teal_slices(
teal_slice(dataname = "iris", varname = "Species", selected = "setosa", keep_na = TRUE)
)
)
# get the actual filter state --> named list with filters
isolate(fpa$get_filter_state())
# remove all_filter_states
fpa$clear_filter_states()
# get the actual filter state --> empty named list
isolate(fpa$get_filter_state())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.