我试图从这个例子中获取省标签中的值:
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而不是州abbr中获得USArrests的价值'谋杀'。该怎么做? 谢谢, 添
答案 0 :(得分:0)
要更改dataLabels格式,您可以添加地图系列,如:
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使用某个点的值,并且从“谋杀”(value = "Murder"
)开始设置值。