[英]Highcharter Map for categories
I am trying to create a Highchart Map of Europe with R for categories instead of numbers. 我正在尝试用R而不是数字创建R的欧洲海图地图。
Lets say I have the dataset below and I want that the Map shows a color for each category. 可以说我有下面的数据集,我希望地图显示每个类别的颜色。 Categories are: "Red", "Blue", "Green". 类别是:“红色”,“蓝色”,“绿色”。
library(highcharter)
mapData <- data_frame(country = c("PT", "FR", "IT", "DE"),
value = c("Red","Blue","Green","Red"))
Then I need the map to show the categories: 然后,我需要地图来显示类别:
hcmap(map = 'custom/europe', data = mapData,
joinBy = c("iso-a2","country"), value = "value")
The problem is that the result gives me black for each country in my data frame
. 问题是,结果使我的data frame
每个国家都感到沮丧。
Here is a suggestion for a possible solution: 这是可能解决方案的建议:
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")))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.