highcharts 地图气泡显示 3 次
highcharts mapbubble display 3 times
我用 highcharter 包(用于 R)制作了这张地图,它是一个 highcharts 包装器,但仍然有 3 个 bubbleLegend,我只想要其中一个
如果有人可以帮助我,也许在 js 方面?
甚至有一个提交解决了 js 中的问题:https://github.com/highcharts/highcharts/commit/63dc48767b3aa00b846631084b286f6605342e22
library(highcharter)
library(dplyr)
mydf <- data.frame(
lat = c(-7.1871, 36.95733, 17.9356, -20.4379, 30.2496, -54.9593,
18.0365, 17.9688, 18, 18.005, 17.9538),
lon = c(129.3989, -121.576, -66.6961, -68.773, 138.6162, -128.3548,
-66.8143, -66.9705, -66.7603, -66.7765, -66.8265),
z = c(4.5, 2.77, 4.1, 5.2, 4.5, 5.1, 2.52, 3.7, 2.68, 2.71, 2.88),
part = c(10,15,8,20,30,12,5,17,21,9,11)
)
mydf <- mydf %>%
mutate(color = case_when(
part < 10 ~ "red",
part < 20 ~ "green",
TRUE ~ "blue"
))
hcmap() %>%
hc_add_series(data = mydf, type = "mapbubble", name = "EarthQuake", maxSize = '12%') %>%
hc_tooltip(useHTML = T,headerFormat='',pointFormat = paste('Location :{point.place}<br> Part: {point.part} <br> Magnitude : {point.z}')) %>%
hc_legend(enabled = TRUE,
title = list(text = "Mon titre"),
bubbleLegend = list(
enabled = TRUE,
borderColor = '#000000',
borderWidth = 3,
color = '#8bbc21',
connectorColor = '#000000',
sizeBy = "z",
ranges = list(
list(
value = 100
)
,
list(
value=70
),
list(
value= 40
),
list(
value= 10
)
)
),
align = "bottom", layout = "horizontal",
floating = TRUE ,valueDecimals = 0,
symbolHeight = 11, symbolWidth = 11, symbolRadius = 0) %>%
hc_colorAxis(
dataClasses = color_classes(breaks = c(0, 10, 20, 100),
colors = c("red","green","blue")
)) %>%
hc_title(text = "Global Seismic Activity") %>%
hc_mapNavigation(enabled = T)%>%
hc_exporting(enabled = TRUE)
您提出 link 的问题已于 2019 年 2 月修复并合并到库中。在我的环境中,我安装了使用 Highcharts 7.2.0
的 Highcharter,它于 2019 年 9 月发布。 https://www.highcharts.com/blog/changelog/
包含修复程序,并且在我的环境中运行良好。我只能看到 1 个气泡图例。
您应该确保您使用的是最新版本的Highcharter。您可以通过鼠标右键点击图表查看版本,然后Inspect element
然后在这里找到版本
告诉我你用的是哪一个。
我用 highcharter 包(用于 R)制作了这张地图,它是一个 highcharts 包装器,但仍然有 3 个 bubbleLegend,我只想要其中一个
如果有人可以帮助我,也许在 js 方面? 甚至有一个提交解决了 js 中的问题:https://github.com/highcharts/highcharts/commit/63dc48767b3aa00b846631084b286f6605342e22
library(highcharter)
library(dplyr)
mydf <- data.frame(
lat = c(-7.1871, 36.95733, 17.9356, -20.4379, 30.2496, -54.9593,
18.0365, 17.9688, 18, 18.005, 17.9538),
lon = c(129.3989, -121.576, -66.6961, -68.773, 138.6162, -128.3548,
-66.8143, -66.9705, -66.7603, -66.7765, -66.8265),
z = c(4.5, 2.77, 4.1, 5.2, 4.5, 5.1, 2.52, 3.7, 2.68, 2.71, 2.88),
part = c(10,15,8,20,30,12,5,17,21,9,11)
)
mydf <- mydf %>%
mutate(color = case_when(
part < 10 ~ "red",
part < 20 ~ "green",
TRUE ~ "blue"
))
hcmap() %>%
hc_add_series(data = mydf, type = "mapbubble", name = "EarthQuake", maxSize = '12%') %>%
hc_tooltip(useHTML = T,headerFormat='',pointFormat = paste('Location :{point.place}<br> Part: {point.part} <br> Magnitude : {point.z}')) %>%
hc_legend(enabled = TRUE,
title = list(text = "Mon titre"),
bubbleLegend = list(
enabled = TRUE,
borderColor = '#000000',
borderWidth = 3,
color = '#8bbc21',
connectorColor = '#000000',
sizeBy = "z",
ranges = list(
list(
value = 100
)
,
list(
value=70
),
list(
value= 40
),
list(
value= 10
)
)
),
align = "bottom", layout = "horizontal",
floating = TRUE ,valueDecimals = 0,
symbolHeight = 11, symbolWidth = 11, symbolRadius = 0) %>%
hc_colorAxis(
dataClasses = color_classes(breaks = c(0, 10, 20, 100),
colors = c("red","green","blue")
)) %>%
hc_title(text = "Global Seismic Activity") %>%
hc_mapNavigation(enabled = T)%>%
hc_exporting(enabled = TRUE)
您提出 link 的问题已于 2019 年 2 月修复并合并到库中。在我的环境中,我安装了使用 Highcharts 7.2.0
的 Highcharter,它于 2019 年 9 月发布。 https://www.highcharts.com/blog/changelog/
包含修复程序,并且在我的环境中运行良好。我只能看到 1 个气泡图例。
您应该确保您使用的是最新版本的Highcharter。您可以通过鼠标右键点击图表查看版本,然后Inspect element
然后在这里找到版本
告诉我你用的是哪一个。