javascript - 当 followPointer 标志打开时,Highcharts 工具提示显示箭头/插入符号
问题描述
followPointer
尽管已打开,但我正在尝试让 Highcharts 笛卡尔图表在我的工具提示上显示插入符号/箭头。
阅读文档,显示插入符号的一种方法是followPointer
关闭。但是,对于我的用途,如果我可以在所有情况下都使用它,那将是理想的。
我尝试在此处检查 Tooltips 的源代码以查看followPointer
代码是如何实现的,也许它会告诉我是否有一个标志可以打开或关闭箭头,但似乎我找不到任何此类东西。
如果你需要,这里有一个小提琴:http: //jsfiddle.net/Malinga/oo2njkhs/2/
解决方案
我在这里找到了答案
您基本上需要覆盖move
在 Highcharts 中实现的方法以设置skipAnchor
为false
.
(function(H) {
H.wrap(H.Tooltip.prototype, 'move', function(proceed, x, y, anchorX, anchorY) {
var tooltip = this,
now = tooltip.now,
animate = tooltip.options.animation !== false && !tooltip.isHidden &&
// When we get close to the target position, abort animation and land on the right place (#3056)
(Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
skipAnchor = tooltip.followPointer || tooltip.len > 1;
skipAnchor = false;
// Get intermediate values for animation
H.extend(now, {
x: animate ? (2 * now.x + x) / 3 : x,
y: animate ? (now.y + y) / 2 : y,
anchorX: skipAnchor ? undefined : animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
anchorY: skipAnchor ? undefined : animate ? (now.anchorY + anchorY) / 2 : anchorY
});
// Move to the intermediate value
tooltip.getLabel().attr(now);
// Run on next tick of the mouse tracker
if (animate) {
// Never allow two timeouts
clearTimeout(this.tooltipTimeout);
// Set the fixed interval ticking for the smooth tooltip
this.tooltipTimeout = setTimeout(function() {
// The interval function may still be running during destroy,
// so check that the chart is really there before calling.
if (tooltip) {
tooltip.move(x, y, anchorX, anchorY);
}
}, 32);
}
});
}(Highcharts));
推荐阅读
- python - 想在数据库中存储html代码,并让它在您单击按钮时出现
- laravel-sanctum - Laravel Sanctum API 令牌安全性
- ios - 为面向 IOS 10 的框架添加 swift UI 支持,
- java - 如何从单选按钮获取值并显示在另一个片段的编辑文本上?
- beautifulsoup - 查找有序的结果列表会显示“未找到结果”和 Beautiful soup
- android - Android - 出现软键盘时 VideoView 隐藏的图像
- javascript - ESLint 未定义/被赋值但未使用
- yii - 如何隐藏 Yii 下拉列表搜索字段?
- python-3.x - 按字母顺序排列公司名称
- mysql - 如何将订单表添加到我的 SQL 数据库?