[英]flot hover instead of click event
我现在面临一个问题:我有一个flot chart,点击它时会显示一个带有数据的模块化窗口。
我需要做同样的事情,但不是点击事件,我需要在悬停时执行此操作。 github上的文档仅显示如何在click事件上执行此操作。 我很难在悬停时做同样的事情。 有人能帮我吗?
悬停在flot上的事件称为“plothover”,因此将该事件绑定到图的容器并设置回调,如下所示:
$(diagramContainer).bind("plothover",function(event, pos, item) {
// event holds the js event, pos holds the (x,y) coordinate, item holds the
// closest data item to the event
});
该项通常有足够的信息为您添加工具提示到数据项,如属性item.pageX和item.pageY,值保存在属性item.datapoint上,您可以找到访问item.series的系列配置属性(如item.series.color)。
使用悬停更改您的功能事件
$(function (){
$("#yourID").hover(function (){
//your code goes here
})
})
将两个处理程序绑定到匹配的元素,在鼠标指针进入和离开元素时执行。
$(function (){
$("#yourID").hover(OnmouseoverFunction, Onmouseoutfunction);
})
function OnmouseoverFunction()
{
//on mouse over code
}
function Onmouseoutfunction()
{
//on mouse outcode
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.