Protovis jQuery 醉酒不适用于点击事件
我在我的图表上工作得很好。 mouseover
事件工作正常,但是当我添加 click
事件时,它没有按照我想要的方式执行 click
事件。
以下是我的代码:
var vis = new pv.Panel()
.width(w)
.height(h);
vis.add(pv.Bar)
.data(data)
.width(4)
.left(function() 5 * this.index)
.height(function(d) Math.round(d*4))
.bottom(0)
.text(function(d) d.toFixed(1))
.event("mouseover", pv.Behavior.tipsy({gravity: "w", fade: true}))
//If I remove the mouseover event, the click event will work but not when both are veing put together.
.event("click", function() self.location = "http://stanford.edu");
vis.render();
任何人都可以帮我解决这个问题吗?
I have tipsy working fine on my chart. The mouseover
event worked fine but when I added a click
event, it doesn't execute the click
event as I wanted.
Below is my code:
var vis = new pv.Panel()
.width(w)
.height(h);
vis.add(pv.Bar)
.data(data)
.width(4)
.left(function() 5 * this.index)
.height(function(d) Math.round(d*4))
.bottom(0)
.text(function(d) d.toFixed(1))
.event("mouseover", pv.Behavior.tipsy({gravity: "w", fade: true}))
//If I remove the mouseover event, the click event will work but not when both are veing put together.
.event("click", function() self.location = "http://stanford.edu");
vis.render();
Can anyone help me solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个解决方法。您可以将点击回调函数传入 pv.Behavior.tipsy 并调用其中的点击事件。
修改 pv.Behavior.tipsy(...) 以传入回调函数:
pv.Behavior.tipsy = function(opts, callback)
.event("mouseover", pv.Behavior.tipsy({gravity: "w", fade: true}, function(){alert('点击回调');}))
修改protovis.tipsy.js中返回函数的最后一行:
返回函数(d) {
…………
$(tip).mouseleave(cleanup).tipsy("show");
如果(回调){
$(提示).click(回调);
}
};
here's a workaround. you can pass in a click callback function into pv.Behavior.tipsy and call the click event within it.
modify pv.Behavior.tipsy(...) to pass in a callback function:
pv.Behavior.tipsy = function(opts, callback)
modify event call to pass in a callback funciton:
.event("mouseover", pv.Behavior.tipsy({gravity: "w", fade: true}, function(){alert('click call back');}))
modify the last line in return function in protovis.tipsy.js:
return function(d) {
.......
$(tip).mouseleave(cleanup).tipsy("show");
if(callback) {
$(tip).click(callback);
}
};