# using a color column from the R dataset
# treemap has an amazing treecolors ability
library(treemap)
library(d3r)
rhd <- random.hierarchical.data()
tm <- treemap(
rhd,
index = paste0("index", 1:3),
vSize = "x",
draw = FALSE
)$tm
sund2b(
d3_nest(tm, value_cols = colnames(tm)[-(1:3)]),
colors = htmlwidgets::JS(
# yes this is a little different, so please pay attention
# "function(d) {return d.color}" will not work
"function(name, d){return d.color || '#ccc';}"
),
valueField = "vSize"
)`
是否可以更改绘图的颜色和字体?现在颜色是基于“ index1”列的,这很好,我想保留它。我只是想选择我自己选择的颜色。我认为这需要JS方面的一些知识,但对此我零知识。