2012-07-05 53 views

回答

1

您是否在自定義節點類型定義中編寫了「contains」函數和「render」函數?如果你還沒有像mouseEnter/onRightClick這樣的事件不會觸發。

這裏是包含自定義節點類型的方法的代碼。

$jit.ForceDirected.Plot.NodeTypes.implement({ 
'icon1': { 
    'render': function(node, canvas){ 
       var ctx = canvas.getCtx(); 
       var img = new Image(); 
       img.src='magnify.png'; 
       var pos = node.pos.getc(true); 
       img.onload = function() { 
         ctx.drawImage(img, pos.x, pos.y); 
       }; 

     }, 
     'contains': function(node,pos){ 
       var npos = node.pos.getc(true); 
       dim = node.getData('dim'); 
       return this.nodeHelper.circle.contains(npos, pos, dim); 
       //return this.nodeHelper.square.contains(npos, pos, dim); 
     } 
    } 
});