Infovis JIT:将点击侦听器添加到边缘 [英] Infovis JIT: add click listener to edge

查看:120
本文介绍了Infovis JIT:将点击侦听器添加到边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图捕捉旭日形图边缘的点击事件。我已经捕获节点上的点击事件。这是我想要的:

  // .. sunburst示例代码
事件:{
enable:true,
enableForEdges:true,
type:'Native',
onClick:function(node,eventInfo,e){$ b $ if(!node)return;
if(node.nodeFrom){
console.log(target is an edge);
} else {
console.log(target is a node);
}
}

但这只捕获节点点击。怎么了?
先谢谢您。

解决方案

问题在于'contains'方法,对于边界类型'hyperline' (sunburst使用的)尚未在infovis库中实现。

包含的方法由库用来确定参数中指定的某个位置是否在边界内。无法使用包含方法获取事件。
因此,您可以在jit.js中实现自己的包含hyperline类型的contains方法,也可以在init方法中将边线类型从'hyperline'更改为'line'。

 边缘:{
可覆盖:true,
类型:'line',//'hyperline'
lineWidth:2,
color:'#777'
}

您将可以捕捉事件对于边缘类型线,因为包含方法是为线类型定义的。


I'm trying to capture a click event on an edge of a sunburst graph. I've already captured click events on nodes. This is what I'm trying:

//..sunburst example code
Events: {  
  enable: true,  
  enableForEdges: true,  
  type: 'Native',  
  onClick: function(node, eventInfo, e){  
    if (!node) return;  
    if(node.nodeFrom){  
      console.log("target is an edge");  
    }else{  
      console.log("target is a node");  
    }  
  }  

But this only captures node clicks. What's wrong? Thank you in advance.

解决方案

The problem is that 'contains' method, for the edge type 'hyperline'(which sunburst uses) is not yet implemented in the infovis library.

Contains method is used by library to know if some position specified in parameters is within the edge or not. You can not get events without contains method. So, you can either implement your own contains method for type hyperline in jit.js or you can simply change the edge type to 'line' from 'hyperline' in init method.

Edge: {
  overridable: true,
  type: 'line',  //'hyperline'
  lineWidth: 2,
  color: '#777'
} 

You will be able to capture events for edge type 'line' because contains method is defined for 'line' type.

这篇关于Infovis JIT:将点击侦听器添加到边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆