在 highcharter 包中使用 highmaps 在省标签中获取值

Get value in province label with highmaps in the highcharter package

我正在尝试从此示例中获取省标签中的值:

library("dplyr")
library('highcharter')
library("viridisLite")

data("USArrests", package = "datasets")
data("usgeojson")

USArrests <- USArrests %>%
  mutate(state = rownames(.))


highchart() %>%
  hc_title(text = "Violent Crime Rates by US State") %>%
  hc_subtitle(text = "Source: USArrests data") %>%
  hc_add_series_map(usgeojson, USArrests, name = "Murder arrests (per 100,000)",
                    value = "Murder", joinBy = c("woename", "state"),
                    dataLabels = list(enabled = TRUE,
                                      format = '{point.properties.postalcode}'))

我想从 dataLabels 中的 USArrests 获取值 'Murder' 而不是州缩写。应该怎么做? 谢谢, 蒂姆

要更改数据标签格式,您可以添加地图系列,例如:

hc_add_series_map(usgeojson, USArrests, name = "Murder arrests (per 100,000)",
                    value = "Murder", joinBy = c("woename", "state"),
                    dataLabels = list(enabled = TRUE,
                                      format = '{point.value}'))

这里重要的是 format = '{point.value}' - 这将使 Highcharts 使用一个点的值,并且从 "Murder" (value = "Murder").

中设置一个点值