You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求修改Highcharter代码:实现hover时不显示数据标签

修改方案

要实现鼠标hover时不显示数据标签(tooltip),只需调整hc_tooltip()的配置,禁用tooltip功能即可。

修改后的完整代码

library(tidyverse)
library(dplyr)
library(purrr)
library(tidyr)
library(highcharter)
DF<-Tooltip_Demo
dataframe<-data.frame(Year=DF$Year,Country=DF$Country,City=DF$City,Discount=DF$Discount,
Sales_amount=DF$Sales_amount,Profit=DF$Profit)
df_table<-tbl_df(dataframe)
df_table
gp <- df_table %>%
arrange(desc(Year)) %>%
distinct(Country, .keep_all = TRUE)
gp2 <- df_table %>%
select(Country, Year,Discount, Sales_amount, Profit) %>%
nest(-Country) %>%
mutate(
data = map(data, mutate_mapping, hcaes(x = Year, y = Profit), drop = TRUE),
data = map(data, list_parse)
) %>%
rename(ttdata = data)
gptot <- left_join(gp,gp2,by="Country")
hchart(
 gptot,
 "point",
 hcaes(Discount,Sales_amount,name = City,size = Profit,group = Country, name = City)

 )  %>%
  hc_xAxis(labels=list(format ='(value) %')) %>%
  hc_yAxis(type = "logarithmic") %>%
  # 禁用tooltip,hover时不再显示数据标签
  hc_tooltip(enabled = FALSE)

说明

原代码中hc_tooltip()配置了自定义的hover内容,将其替换为hc_tooltip(enabled = FALSE)后,即可完全关闭鼠标hover时的数据标签显示。如果后续需要重新开启tooltip,只需将enabled参数设为TRUE,并恢复原有的自定义配置即可。

内容的提问来源于stack exchange,提问作者Yashdeep Vani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 23:57:27