anychart - 鼠标悬停在图表上发出的 event.point.index 有什么意义?
问题描述
我试图在一个简单的折线图上确定用户鼠标位置的最近 x 值。有没有办法做到这一点?
我已经尝试向图表实例添加一个 pointMouseOver 和 pointsHover 侦听器,虽然它们发出某种索引,但索引的数量远远超过图表中 x 值的数量(我的图表有大约 600 个 x 值,最大发出的指数约为 1000)。
this.chart.listen('pointMouseOver', function (event) {
console.log(event.iterator.getIndex())
console.log(event)
})
返回一些任意索引而不是最接近的 x 值。
解决方案
在查看图表 API 参考时设法自己回答了我的问题 - 要在 pointsHover 上获取最接近的 x 值,请调用 event.point.get('x')。https://playground.anychart.com/api/_samples/anychart.enums.EventType.pointsHover
推荐阅读
- r - 如何从具有正确轮廓的 shapefile 中获取子集?
- flutter - 从列表中删除一些但不是所有重复项 (Flutter)
- php - 如何覆盖 saveAction 背包 laravel 管理面板
- ios - 在使用 moveRowAt 方法时修复 Top Row
- java - 未找到 EJB 模块
- css - 如何在手机中隐藏箭头
- php - 在它的子类中找不到 PHP 父数据库类
- mysql - 我如何在视图文件上使用 NOT IN 查询
- node.js - Nodejs:握手被服务器终止:403 rabbitmq
- c# - 在 ASP.NET Core MVC 中将模型转换为 JSON 对象