【发布时间】:2020-02-11 03:15:21
【问题描述】:
我正在尝试找出一种在 Highcharts Gantt 依赖路径上添加悬停工具提示的方法;但不确定最好的方法,因为似乎没有原生配置属性来与依赖路径和端点交互。
我从在呈现的.highcharts-point-connecting-path 类上绑定mouseenter 事件的方法开始;但是,返回的对象似乎没有任何可识别的 data 属性来帮助将 mouseenter 对象与保存工具提示数据的对象联系起来。
$('#gchart-container').on('mouseenter','.highcharts-point-connecting-path',function(event) {
console.log( this );
});
// returns
// <path fill="none" opacity="1" stroke="#3ABFDA" stroke-width="1" class="highcharts-point-connecting-path highcharts-color-4" d="M 17.5 125.5 L 30.5 125.5 L 30.5 100.5 L 30.5 100.5 L 30.5 25.5 L 17.5 25.5"></path>
由于我已经将所有原始系列数据存储在我的 $data 对象中,如果有一种方法可以将自定义数据属性添加到将显示在 HTML 节点上的系列依赖项中,那么这个解决方案就可以工作。例如。添加自定义属性,如 data-series-id 或其他东西:
// <path fill="none" data-series-id="aa33233dd" opacity="1" stroke="#3ABFDA" stroke-width="1" class="highcharts-point-connecting-path high..... blah blah blah"></path>
然后可以访问$data['aa33233dd'] 以获取适当的信息...理论上。
有什么想法吗?或者有没有更好的方法来做到这一点?
【问题讨论】:
-
如果无法实现上述目标 - 那么可能只需更新
mouseover上的path对象的strokeWidth即可;但是this没有setAttribute函数 - 那么更新 Highcharts SVG 线条和重绘(如有必要)的适当方法是什么?
标签: javascript highcharts gantt-chart highcharts-gantt