Skip to contents

Create a Circle Packing Chart

Usage

v_circlepacking(
  vc,
  mapping = NULL,
  data = NULL,
  name = NULL,
  drill = TRUE,
  use_root = FALSE,
  fill_opacity = JS("d => d.isLeaf ? 0.75 : 0.25;"),
  label_visible = JS("d => d.depth === 1;"),
  ...,
  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.

use_root

Add a root level in the hierarchy, can be TRUE (in this case root level will be named root) or a character (use as the name for the root level).

fill_opacity

Fill opacity, a JS function determining the opacity of the elements.

label_visible

A JS function to control visibility of labels.

...

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)

vchart(countries_gdp) %>%
  v_circlepacking(
    aes(lvl1 = REGION_UN, lvl2 = SUBREGION, lvl3 = ADMIN, value = GDP_MD)
  )
# With root level vchart(countries_gdp) %>% v_circlepacking( aes(lvl1 = REGION_UN, lvl2 = SUBREGION, lvl3 = ADMIN, value = GDP_MD), use_root = "World" )
# Custom colors vchart(countries_gdp) %>% v_circlepacking( aes(lvl1 = REGION_UN, lvl2 = SUBREGION, lvl3 = ADMIN, value = GDP_MD) ) %>% v_scale_color_manual(c( Oceania = "#E6AB02", Africa = "#1B9E77", Americas = "#D95F02", Asia = "#E7298A", Europe = "#66A61E", Antarctica = "#7570B3" ))
# Bubble Chart vchart(countries_gdp) %>% v_circlepacking( aes(ADMIN, GDP_MD), label_visible = JS("d => d.value > 261921;"), # 261921 = 3rd Qu. )