Skip to contents

Adds a legend based on a specified color palette.

Usage

output_legend(palette = "", variable = NULL, dataview = NULL,
  id = NULL, click = NULL, subto = NULL, class = "", show_na = TRUE)

Arguments

palette

Name of an included color palette, or palette selection input; for discrete scales, one of "rdylbu7", "orrd7", "gnbu7", "brbg7", "puor7", "prgn6", "reds5", "greens5", "greys4", "paired4" (from colorbrewer); for continuous scales, one of "grey", "brown", "purple", "prgn", "puor", "rbbu", "prgn", "vik" (default), or "lajolla".

variable

Name of a variable or ID of a variable selector to display values of. Defaults to the y variable of dataview if one is specified.

dataview

The ID of an input_dataview component.

id

Unique ID of the legend element.

click

The ID of an input to set to an entity's ID near the current cursor location on the current scale.

subto

A vector of output IDs to receive hover events from.

class

Class names to add to the legend element.

show_na

Logical; if FALSE, does not add the separate section showing the color of missing values.

Value

A character vector of the contents to be added.

Examples

output_legend()
#>  [1] "<div class=\"legend-wrap\">"                                              
#>  [2] "<div class=\"legend-na\">"                                                
#>  [3] "<div class=\"legend-ticks\"></div>"                                       
#>  [4] "<div class=\"legend-scale\"><span class=\"na\"></span></div>"             
#>  [5] "<div class=\"legend-summary\"><p>NA</p></div>"                            
#>  [6] "</div>"                                                                   
#>  [7] "<div id=\"legend\" data-autoType=\"legend\" class=\"auto-output legend\">"
#>  [8] "<div class=\"legend-ticks\"></div>"                                       
#>  [9] "<div class=\"legend-scale\"></div>"                                       
#> [10] "<div class=\"legend-summary\"></div>"                                     
#> [11] "</div>"                                                                   
#> [12] "</div>"