Skip to contents

Create a Treemap Chart

Usage

v_treemap(
  vc,
  mapping = NULL,
  data = NULL,
  name = NULL,
  drill = TRUE,
  ...,
  serie_id = NULL,
  data_id = NULL
)

Arguments

vc

A chart initialized with vchart().

mapping

Default list of aesthetic mappings to use for chart.

data

Default dataset to use for chart. If not already a data.frame, it will be coerced to with as.data.frame.

name

Name for the serie, only used for single serie (no color/fill aesthetic supplied).

drill

Drill-down function switch.

...

Additional parameters for the serie.

data_id, serie_id

ID for the data/serie, can be used to further customize the chart with v_specs().

Value

A vchart() htmlwidget object.

Examples


library(vchartr)

# Basic Treemap Chart
vchart(countries_gdp) %>%
  v_treemap(aes(lvl1 = REGION_UN, lvl2 = ADMIN, value = GDP_MD))
# With labels vchart(countries_gdp) %>% v_treemap( aes(lvl1 = REGION_UN, lvl2 = ADMIN, value = GDP_MD), label = list(visible = TRUE) )
# Show all levels vchart(countries_gdp) %>% v_treemap( aes(lvl1 = REGION_UN, lvl2 = ADMIN, value = GDP_MD), label = list(visible = TRUE), nonLeaf = list(visible = TRUE), nonLeafLabel = list(visible = TRUE, position = "top") )