I'm struggling with adding an edge event listener to the HyperTree object edge in Javascript Infovis toolkit library. I am aware of the fact, that everything revolves around "contains" method, which is not implemented for default edge type, which is "hyperline".
What I did: I've added code
Edge: {
overridable: true,
type: 'line',
lineWidth: 4,
color: '#bbb'
}
to the HyperTree constructor. I've aldo added something like
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");
}
}
}
following this question.
I did check in Google Chrome debugger, that contains
method is triggered on line
edgeHelper
objects in jit source library. And when I click on some edge, all contains
invokations return true
only for one edge, while returning false
for the rest of the objects.
Commenting out lines enableForEdges
and type: 'Native'
prevents aby triggers on jit edgeHelper
line contains
methods.
but if I put a breakpoint on added onClick listener, I get node == false
whenever I click outside the node (regardless) whether I click on edge or on empty space.
So the question in general: how do I correctly add event listener to edge in HyperTree?
And more narrow question: how can I be sure, that when contains
for some line return true, it actually triggers a onClick listener, while passing an edge there, rather than a false
.
There is a bug in jit.js. I've submitted a pull-request.