v_circlepacking | R Documentation |
Create a Circle Packing Chart
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
)
vc |
A chart initialized with |
mapping |
Default list of aesthetic mappings to use for chart. |
data |
Default dataset to use for chart. If not already
a |
name |
Name for the serie, only used for single serie (no |
drill |
Drill-down function switch. |
use_root |
Add a root level in the hierarchy, can be |
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 |
A vchart()
htmlwidget
object.
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.
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.