v_sunburst | R Documentation |
Create a Sunburst Chart
v_sunburst(
vc,
mapping = NULL,
data = NULL,
name = NULL,
drill = TRUE,
gap = 5,
...,
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. |
gap |
Layer gap, supports passing an array to configure layer gaps layer by layer. |
... |
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)
# Create a sunburst and auto hide labels
vchart(countries_gdp) %>%
v_sunburst(
aes(lvl1 = REGION_UN, lvl2 = SUBREGION, lvl3 = ADMIN, value = GDP_MD),
gap = 10,
labelAutoVisible = list(
enable = TRUE
),
labelLayout = list(
align = "center",
rotate = "radial"
)
)
# Custom tooltip
vchart(countries_gdp) %>%
v_sunburst(
aes(lvl1 = REGION_UN, lvl2 = SUBREGION, lvl3 = ADMIN, value = GDP_MD)
) %>%
v_specs_tooltip(
mark = list(
title = list(
value = JS("val => val?.datum?.map(data => data.name).join(' / ')")
)
)
)
# Custom layout options
vchart(countries_gdp) %>%
v_sunburst(
aes(lvl1 = REGION_UN, lvl2 = SUBREGION, lvl3 = ADMIN, value = GDP_MD),
gap = 0,
innerRadius = c(0, 0.4, 0.8),
outerRadius = c(0.3, 0.7, 0.85),
labelAutoVisible = list(
enable = TRUE,
circumference = 1
),
labelLayout = list(
list(
align = "center",
rotate = "tangential",
offset = 0
),
NULL,
list(
align = "start",
rotate = "radial",
offset = 15
)
)
) %>%
v_specs(padding = 70)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.