jQuery flot mouseleave 对我不起作用
我对 jQuery.flot.js 和 flot.pie.js 进行了一些修改,以在我的饼图画布上制作 mouseleave 效果。
在第 585 行 flot.pie.js
function onMouseMove(e) {
triggerClickHoverEvent('plothover', e);
}
function onMouseLeave(e) {
triggerClickHoverEvent('plotleave', e);
}
function onClick(e) {
triggerClickHoverEvent('plotclick', e);
}
在第 127 行 flot.pie.js
if (options.series.pie.show && options.grid.hoverable) {
eventHolder.unbind('mousemove').mousemove(onMouseMove);
eventHolder.unbind('mouseleave').mouseleave(onMouseLeave);
}
在我的 javascript mysite.html
$("#graph1").bind("plothover", pieHover);
$("#graph1").bind("plotleave", pieLeave);
$("#graph1").bind("plotclick", pieClick);
函数 mysite.js 中。 html
function pieHover(event, pos, obj) {
if (!obj) return;
var what = obj.series.name;
$("a[name=" + what + "]").addClass("hover");
$("#world #" + what + " path", svg.root()).attr("fill", "url(#orange)");
$("#world #" + what + " path.water", svg.root()).attr("fill", "#92D7E7");
}
function pieLeave(event, pos, obj) {
if (!obj) return;
var what = obj.series.name;
$("a[name=" + what + "]").removeClass("hover");
$("#world #" + what + " path", svg.root()).attr("fill", "#68CDF2");
$("#world #" + what + " path.water", svg.root()).attr("fill", "#B9E4EE");
}
function pieClick(event, pos, obj) {
if (!obj) return;
percent = parseFloat(obj.series.percent).toFixed(2);
alert('' + obj.series.label + ': ' + percent + '%');
}
我的pieLeave函数被完全忽略了。问题是什么?感谢您的帮助。
更多信息:flot 示例
I've modify my jQuery.flot.js and flot.pie.js a bit, to make a mouseleave effect on my pie canvas.
at line 585 flot.pie.js
function onMouseMove(e) {
triggerClickHoverEvent('plothover', e);
}
function onMouseLeave(e) {
triggerClickHoverEvent('plotleave', e);
}
function onClick(e) {
triggerClickHoverEvent('plotclick', e);
}
at line 127 flot.pie.js
if (options.series.pie.show && options.grid.hoverable) {
eventHolder.unbind('mousemove').mousemove(onMouseMove);
eventHolder.unbind('mouseleave').mouseleave(onMouseLeave);
}
in my javascript mysite.html
$("#graph1").bind("plothover", pieHover);
$("#graph1").bind("plotleave", pieLeave);
$("#graph1").bind("plotclick", pieClick);
the functions mysite.html
function pieHover(event, pos, obj) {
if (!obj) return;
var what = obj.series.name;
$("a[name=" + what + "]").addClass("hover");
$("#world #" + what + " path", svg.root()).attr("fill", "url(#orange)");
$("#world #" + what + " path.water", svg.root()).attr("fill", "#92D7E7");
}
function pieLeave(event, pos, obj) {
if (!obj) return;
var what = obj.series.name;
$("a[name=" + what + "]").removeClass("hover");
$("#world #" + what + " path", svg.root()).attr("fill", "#68CDF2");
$("#world #" + what + " path.water", svg.root()).attr("fill", "#B9E4EE");
}
function pieClick(event, pos, obj) {
if (!obj) return;
percent = parseFloat(obj.series.percent).toFixed(2);
alert('' + obj.series.label + ': ' + percent + '%');
}
My pieLeave function is totally ignored. What is the problem? Thanks for the help.
More information: flot example
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,发生了。您根本无法在绘图上使用 mouseleave,因为绘图是整个画布容器,如果将所有内容绑定到 mousemove 并检查对象的 na,则执行此操作的唯一方法
Okay, happened. You simply can't use the mouseleave on the plot because the plot is the whole canvas container, the only way to do this if binds everything to mousemove and check the object's na