categoricalColorFilter {vfinputs}R Documentation

Add a visual filter input for categorical data

Description

Add a visual filter input for categorical data

Usage

categoricalColorFilter(inputId, ...)

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

## 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)

}


[Package vfinputs version 0.1.0 Index]