Getting started
Interactivity
Listen for node events
node.on('pointerover', (event) => {
node.style('opacity', '0.5')
ui.update()
})
node.on('pointerout', (event) => {
node.style('opacity', '1')
ui.update()
})Call ui.update() after changing node styles in an event handler.
Remove node listeners
To remove a node listener while the node is still active, pass the same function to node.off(). Destroying a node removes its listeners automatically:
function onPointerOver() {
console.log('node has been hovered')
}
node.on('pointerover', onPointerOver)
node.off('pointerover', onPointerOver)For the complete list of supported events, event data, and propagation rules, see Events.