【问题标题】:Highlight custom node on mouse enter鼠标输入时突出显示自定义节点
【发布时间】:2012-07-05 15:35:54
【问题描述】:

我正在创建自定义节点,我想在鼠标输入时突出显示。不幸的是,mouseEnter 事件没有触发。我也不知道在mouseEntermouseLeave之后如何渲染节点。

【问题讨论】:

    标签: infovis thejit


    【解决方案1】:

    您是否在自定义节点类型定义中编写了“包含”函数和“渲染”函数?如果没有,则不会触发 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); 
          } 
      }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-24
      • 1970-01-01
      • 2020-05-11
      相关资源
      最近更新 更多