删除 highcharter 地图工具提示中的“系列 1”文本

问题描述 投票:0回答:1

在我的交互式 Highcharter 地图中,我想删除工具提示中显示“Series 1”的文本,并将该部分留空。我还想删除国家/地区名称后面的冒号和 1。我怎样才能做到这一点?我仍然想在工具提示中保留国家/地区名称。 (https://i.stack.imgur.com/2KLKG.png)

这是我的代码:

library(highcharter)
library(maps)

countrylabeldata<-iso3166

countrylabeldata <- rename(countrylabeldata, "iso-a3" = a3)

Swahili_countries <- c("BDI","COD", "KEN", "OMN", "RWA", "TZA", "UGA")

countrylabeldata$include <- ifelse(countrylabeldata$`iso-a3` %in% Swahili_countries, 1, 0)


hcmap(
  map = "custom/world-highres3", 
  data = countrylabeldata, 
  joinBy = "iso-a3",
  value = "include",
  showInLegend = FALSE,
  nullColor = "#DADADA",
  download_map_data = TRUE,
) %>%
  hc_mapNavigation(enabled = T) %>%
  hc_legend("none") %>%
  hc_title(text = "Countries with Highest Prevalence of Swahili Speakers")%>%
  hc_caption(text="Data from CIA World Factbook")
r highcharts tooltip r-highcharter
1个回答
0
投票

要摆脱“Series 1”,请将变量“name”设置为空格,即

name = ""
。至于 : 0 和 : 1,您可以通过删除 hcmap 中的变量
value = "include"
来消除它,但它会消除您突出显示的特定国家/地区。您想保留地图上突出显示的国家/地区吗?有人可能有比我更有效的答案。

这是我编辑您的代码的方式:

hcmap(
 map = "custom/world-highres3", 
 data = countrylabeldata, 
 joinBy = "iso-a3",
 showInLegend = FALSE,
 value = "include",
 nullColor = "#DADADA",
 name = "",
 download_map_data = TRUE) %>%
hc_mapNavigation(enabled = T) %>%
hc_legend("none") %>%
hc_title(text = "Countries with Highest Prevalence of Swahili Speakers")%>%
hc_caption(text= "Data from CIA World Factbook")
© www.soinside.com 2019 - 2024. All rights reserved.