Skip to contents

Add a gradient legend in a topogram() widget.

Usage

topogram_legend(
  topo,
  colors = NULL,
  labels = NULL,
  formatter = NULL,
  title = NULL,
  direction = c("h", "v"),
  height = "250px",
  width = "250px"
)

Arguments

topo

A topogram() / topogram_proxy() htmlwidget object.

colors

Vector of colors used in legend, default is to use colors used in topogram().

labels

Labels to display for values, default is to use range of values used in topogram().

formatter

Function to format labels, like scales::label_number().

title

Title for the legend.

direction

Direction: horizontal or vertical.

height, width

Height, width for legend. For gradient legend it represent the size of the dradient according to direction.

Value

A topogram() / topogram_proxy()htmlwidget object.

Examples

library(topogram)

topogram(world, value = "pop_est") %>% 
  topogram_legend(title = "Population")
#> Warning: 'geojsonlint' not installed, skipping GeoJSON linting

topogram(world, value = "pop_est", palette = "Blues") %>% topogram_legend( title = NULL, formatter = scales::label_comma(), direction = "v" ) #> Warning: 'geojsonlint' not installed, skipping GeoJSON linting