# NOT RUN {
library(tidyverse)
library(highcharter)
library(RColorBrewer)
tibble(
index1 = sample(LETTERS[1:5], 500, replace = T),
index2 = sample(LETTERS[6:10], 500, replace = T),
index3 = sample(LETTERS[11:15], 500, replace = T),
value = rpois(500, 5),
color_value = rpois(500, 5)
) %>%
hctreemap2(
group_vars = c("index1", "index2", "index3"),
size_var = "value",
color_var = "color_value",
layoutAlgorithm = "squarified",
levelIsConstant = FALSE,
levels = list(
list(level = 1, dataLabels = list(enabled = TRUE)),
list(level = 2, dataLabels = list(enabled = FALSE)),
list(level = 3, dataLabels = list(enabled = FALSE))
)
) %>%
hc_colorAxis(
minColor = brewer.pal(7, "Greens")[1],
maxColor = brewer.pal(7, "Greens")[7]
) %>%
hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
Value: {point.value:,.0f}<br>
Color Value: {point.colorValue:,.0f}")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab