문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top