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.
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); } };
精彩评论