我现在面临一个问题:我有一个浮动图表,当它被点击时,它会显示一个带有数据的模块化窗口。
我需要做同样的事情,但我需要在悬停时执行此操作,而不是单击事件。github 上的文档仅显示如何在单击事件上执行此操作。我很难在悬停时做同样的事情。有人能帮我吗?
我现在面临一个问题:我有一个浮动图表,当它被点击时,它会显示一个带有数据的模块化窗口。
我需要做同样的事情,但我需要在悬停时执行此操作,而不是单击事件。github 上的文档仅显示如何在单击事件上执行此操作。我很难在悬停时做同样的事情。有人能帮我吗?
在 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通常有足够的信息让你给data item添加一个tooltip,比如属性item.pageX和item.pageY,值保存在属性item.datapoint上,你可以找到访问item.series的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
}