categoricalColorFilter: Add a visual filter input for categorical data

Description Usage Arguments Value Server value See Also Examples

View source: R/input-colorfilters.R

Description

Add a visual filter input for categorical data

Usage

1

Arguments

inputId

The input slot that will be used to access the value.

...

Arguments passed on to categoricalLegend

label

Display label for the control, or NULL for no label.

class

The CSS class of the input div element to match with any filter toggling functions. Default class is "categorical-color-filter".

values

List of character vectors that will match with the colors or palette in the order provided by both.

data

Alternative vector to extract values with "unique()" function.

colors

Colours to match with values; must be a valid argument to grDevices::col2rgb(). This can be a character vector of "#RRGGBB" or "#RRGGBBAA", colour names from grDevices::colors(), or a positive integer that indexes into grDevices::palette().

palette

A function that outputs a list of colors.

orient

Orientation of the legend. Can be "bottom" (default, horizontal with labels below), "top" (horizontal with labels above), "left" (vertical with labels on the left) and "right" (vertical with labels on the right).

size

Absolute length in pixels of the color bar; becomes width or height depending on value of orient. Default is 220.

multiple

Is selection of multiple items allowed? Default is TRUE. With FALSE, selecting one item will de-select the others.

Value

A visual filter input control that can be added to a UI definition

Server value

start and end bounds of a selection. The default value (or empty selection) is NULL.

See Also

categoricalLegend()

Other visual filters: continuousColorFilter(), discreteColorFilter()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Only run examples in interactive R sessions
if (interactive()) {

ui <- fluidPage(
  categoricalColorFilter("filter", data = sort(mtcars$gear), orient = "right",
                           palette = RColorBrewer::brewer.pal(8, "Dark2")),
  verbatimTextOutput("value")
)
server <- function(input, output) {
  output$value <- output$selection <- renderPrint({
  if (!is.null(input$filter)) {
    format(input$filter)
  }
})
}

shinyApp(ui, server)

ui <- fluidPage(
  categoricalColorFilter("filter", label = p("Categorical filter:"),
                           palette = RColorBrewer::brewer.pal(3, "Accent"),
                           values = list("a","b","c")),
  verbatimTextOutput("values")
)
server <- function(input, output) {
  output$value <- output$selection <- renderPrint({
  if (!is.null(input$filter)) {
    format(input$filter)
  }
})
}
shinyApp(ui, server)

}

rhenkin/vfinputs documentation built on Oct. 23, 2020, 1:30 a.m.