简体   繁体   中英

Protovis jQuery tipsy doesn't work with click event

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?

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); } };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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