繁体   English   中英

Protovis jQuery Tipsy 不适用于单击事件

[英]Protovis jQuery tipsy doesn't work with click event

我在我的图表上工作得很好。 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();

谁能帮我解决这个问题?

这是一个解决方法。 您可以将点击回调函数传入 pv.Behavior.tipsy 并在其中调用点击事件。

  1. 修改 pv.Behavior.tipsy(...) 传入一个回调函数:

    pv.Behavior.tipsy = 函数(选择,回调)

  2. 修改事件调用以传入回调函数:

    .event("mouseover", pv.Behavior.tipsy({gravity: "w",fade: true}, function(){alert('click call back');}))

  3. 修改protovis.tipsy.js中return函数的最后一行:

    return function(d) { ....... $(tip).mouseleave(cleanup).tipsy("show"); if(callback) { $(tip).click(callback); } };

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM