类别的 Highcharter 地图

Highcharter Map for categories

我正在尝试使用 R 作为类别而不是数字来创建欧洲 Highchart 地图。

假设我有下面的数据集,我希望地图为每个类别显示一种颜色。类别为:"Red"、"Blue"、"Green"。

library(highcharter)
mapData <- data_frame(country = c("PT", "FR", "IT", "DE"), 
value = c("Red","Blue","Green","Red"))

然后我需要地图来显示类别:

hcmap(map = 'custom/europe', data = mapData,
  joinBy = c("iso-a2","country"), value = "value")

问题是 data frame.

中的每个国家的结果都是黑色的

这里有一个可能的解决方案建议:

mapData <- tibble(country = c("PT", "FR", "IT", "DE"),  
                  value = c(1, 2, 3, 1))

hcmap(map = 'custom/europe', data = as.data.frame(mapData),
  joinBy = c("iso-a2","country"), value = "value") %>%
  hc_colorAxis(dataClassColor="category", 
     dataClasses = list(list(from=1, to=1, color="red", name="PT-DE"),
                        list(from=2, to=2, color="blue", name="FR"),
                        list(from=3, to=3, color="green", name="IT")))