我想在高级地图中更改图例的标签格式。我的值从 0 到 2000 亿不等。第一步,即千 (k) 和百万 (M),没问题,但我需要更改十亿“G”的缩写。
我不太擅长 javascript,因此我不知道如何在 hc_legend() 函数中编写格式命令以将“G”更改为“B”,同时将“k”表示千,“M”表示百万.
这是一个小例子,可以看到 highcharter 使用“G”表示数十亿。
library(highcharter)
df = data.frame(
Country = c("AT","BE","CH","DE","FR","IT"),
variable = rnorm(n = 6, mean = 120000000000, sd = 20000000000)
)
hcmap(map = "custom/europe",
data = df, joinBy = c("hc-a2", "Country"), value = "variable", name = "variable",
dataLabels = list(enabled = TRUE, format = '{point.name}'),
borderColor = "#FAFAFA", borderWidth = 0.1,
tooltip = list(valueDecimals = 0, valuePrefix = "€", valueSuffix = "")) %>%
hc_mapNavigation(enabled = TRUE)
#hc_legend(enabled = TRUE, format = "{value}B") #basically a placeholder, as I dont know how to proceed