library(dplyr)
df <- tibble(
name = c("earth", "mars", "venus"),
value = c(30, 40, 30),
# 1st level
itemStyle = tibble(color = c(NA, "red", "blue")),
# embedded styles, optional
children = list(
tibble(
name = c("land", "ocean"),
value = c(10, 20),
# 2nd level
children = list(
tibble(name = c("forest", "river"), value = c(3, 7)),
# 3rd level
tibble(
name = c("fish", "kelp"),
value = c(10, 5),
children = list(
tibble(name = c("shark", "tuna"), value = c(2, 6)),
# 4th level
NULL # kelp
)
)
)
),
tibble(name = c("crater", "valley"), value = c(20, 20)),
NULL # venus
)
)
df |>
e_charts() |>
e_treemap()
Run the code above in your browser using DataLab