簡體   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