开发者

Protovis jQuery tipsy doesn't work with click event

开发者 https://www.devze.com 2023-03-22 19:06 出处:网络
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.

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&quo开发者_开发百科t;, 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?


here's a workaround. you can pass in a click callback function into pv.Behavior.tipsy and call the click event within it.

  1. modify pv.Behavior.tipsy(...) to pass in a callback function:

    pv.Behavior.tipsy = function(opts, callback)

  2. modify event call to pass in a callback funciton:

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

  3. modify the last line in return function in protovis.tipsy.js:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号