highcharts - 在 Highcharts 包装气泡外圈上显示 dataLabels 或工具提示
问题描述
如何显示外圈的数据标签或工具提示packedbubble
?
例如,在全球碳排放(2014 年)样本中,当悬停在每个大陆上时,我需要显示每个大陆的工具提示。或者如果可能的话,为每个人显示数据标签
解决方案
请注意,外圈只是一条没有任何属性(如 x、y 等)的路径,因此它不适用于 Highcharts 工具提示功能。我想到的唯一解决方案是在此路径上的鼠标悬停事件上创建自定义工具提示。
演示:https ://jsfiddle.net/BlackLabel/9gkdfsnj/
代码:
events: {
render() {
var
chart = this,
series = chart.series[0],
graphic = series.parentNode.graphic,
tooltip = document.getElementById('tooltip'),
text;
text = "Sum value: " + Math.floor(series.yData.reduce((a, b) => a + b, 0));
graphic.element.onmouseover = function() {
tooltip.style.visibility = "visible";
tooltip.innerHTML = text;
tooltip.style.left = graphic.x + (tooltip.offsetWidth /2) - chart.plotLeft + 'px';
tooltip.style.top = graphic.y + graphic.height / 2 + 'px'
}
graphic.element.onmouseout = function() {
tooltip.style.visibility = "hidden"
}
}
}
这只是一个简单的示例,请随时改进。
推荐阅读
- python - Pytorch torch.load ModuleNotFoundError:没有名为“utils”的模块
- python - nginx + uwsgi + flask + selenium Selenium 驱动程序未打开
- swift - RealmSwift 不保存属性
- android - Google Play 控制台显示我的应用获得了后台位置权限,但我的应用没有
- vue.js - Vuejs上下文中chartjs的闪烁图表和getcontext错误
- java - 当请求没有匹配的 API 时,为什么我的控制器调用不同的 API?
- javascript - 未捕获的 ReferenceError:AddAnime 未在 HTMLInputElement.onclick 中定义(AnimeSite.html:51)
- google-drive-api - 如何访问应用程序数据文件夹中的所有文件
- python - lambda 什么时候开始捕获自由变量?
- python - 将导入的变量作为参数时,“os”包中的某些函数行为异常