React Sankey - Hover

User Interaction

When a sankey node or link is hovered over or pressed, it applies the appearance specified in the node.hoverStyle or link.hoverStyle object. In the following code, these objects are used to make nodes half-opaque and make the links' border visible:

App.js
  • import React from 'react';
  • import Sankey, {
  • Node,
  • Link,
  • Border,
  • HoverStyle
  • } from 'devextreme-react/sankey';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Sankey ... >
  • <Node ... >
  • <HoverStyle opacity={0.5} />
  • </Node>
  • <Link>
  • <HoverStyle>
  • <Border visible={true} />
  • </HoverStyle>
  • </Link>
  • </Sankey>
  • );
  • }
  • }
  •  
  • export default App;

Set hoverEnabled to false if nodes and links should not react when they are hovered over or pressed:

App.js
  • import React from 'react';
  • import Sankey from 'devextreme-react/sankey';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Sankey hoverEnabled={false} />
  • );
  • }
  • }
  •  
  • export default App;

API

To change a node or link's hover state, pass true or false to their hover(state) method. You can call the isHovered() method to check the current state.

App.js
  • import React from 'react';
  •  
  • class App extends React.Component {
  • toggleItemHoverState (item) {
  • item.hover(!item.isHovered());
  • }
  • }
  •  
  • export default App;
See Also

Events

The Sankey UI component raises individual events for nodes and links when their hover state changes. You can handle them with functions. If the handling functions are not going to be changed at runtime, assign them to the onNodeHoverChanged and onLinkHoverChanged properties when you configure the UI component. To check whether the sankey element is being hovered over, call its isHovered() method.

App.js
  • import React from 'react';
  • import Sankey from 'devextreme-react/sankey';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Sankey
  • onNodeHoverChanged={this.onNodeHoverChanged}
  • onLinkHoverChanged={this.onLinkHoverChanged}
  • />
  • );
  • }
  • onNodeHoverChanged (e) {
  • if(e.target.isHovered()) {
  • // Commands to execute when the pointer enters a node
  • } else {
  • // Commands to execute when the pointer leaves a node
  • }
  • },
  • onLinkHoverChanged (e) {
  • if(e.target.isHovered()) {
  • // Commands to execute when the pointer enters a link
  • } else {
  • // Commands to execute when the pointer leaves a link
  • }
  • }
  • }
  •  
  • export default App;
See Also