我很努力將邊緣事件偵聽器添加到Javascript Infovis工具箱庫中的HyperTree對象邊緣。我意識到這樣一個事實,即一切都圍繞着「包含」方法,而這個方法並沒有針對默認邊緣類型實現,即「超線性」。Javascript infovis工具包(JIT)在HyperTree中添加邊緣事件偵聽器
我做了什麼: 我已經添加代碼
Edge: {
overridable: true,
type: 'line',
lineWidth: 4,
color: '#bbb'
}
到超樹的構造。 我醛補上一句
Events: {
enable: true,
enableForEdges: true,
type: 'Native',
onClick: function (node, eventInfo, e)
if (!node) return;
alert(node);
if (node.nodeFrom) {
alert("target is a node");
} else {
alert("target is an edge");
}
}
}
以下this question。 我在Google Chrome調試器中檢查過,line
edgeHelper
對象在jit源庫中觸發contains
方法。當我點擊某個邊緣時,所有contains
調用僅針對一個邊緣返回true
,而其他對象返回false
。
註釋掉線enableForEdges
和type: 'Native'
防止ABY觸發器上JIT edgeHelper
線contains
方法。
但是如果我在添加的onClick監聽器上放置了一個斷點,每當我單擊節點外(無論)是否點擊邊或空的空間時,我都會得到node == false
。
所以一般的問題是:如何正確添加事件監聽器到HyperTree中的邊緣?
還有一個更窄的問題:我怎麼能確定,當某個行的contains
返回true時,它實際上觸發了一個onClick偵聽器,同時在那裏傳遞一個邊,而不是一個false
。