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:
- $(function() {
- $("#sankeyContainer").dxSankey({
- // ...
- node: {
- hoverStyle: {
- opacity: 0.5
- }
- },
- link: {
- hoverStyle: {
- border: {
- visible: true
- }
- }
- }
- });
- });
Set hoverEnabled to false if nodes and links should not react when they are hovered over or pressed:
- $(function() {
- $("#sankeyContainer").dxSankey({
- // ...
- hoverEnabled: false
- });
- });
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.
- var toggleItemHoverState = function(item) {
- item.hover(!item.isHovered());
- }
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.
- $(function() {
- $("#sankeyContainer").dxSankey({
- // ...
- onNodeHoverChanged: function(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: function(e) {
- if(e.target.isHovered()) {
- // Commands to execute when the pointer enters a link
- } else {
- // Commands to execute when the pointer leaves a link
- }
- }
- });
- });
If you are going to change the event handlers at runtime or if you need several handlers for a single event, subscribe to the hover-related events using the on(eventName, eventHandler) method.
- var nodeHoverChangedHandler1 = function(e) {
- // First handler of the "nodeHoverChanged" event
- };
- var nodeHoverChangedHandler2 = function(e) {
- // Second handler of the "nodeHoverChanged" event
- };
- $("#sankeyContainer").dxSankey("instance")
- .on("nodeHoverChanged", nodeHoverChangedHandler1)
- .on("nodeHoverChanged", nodeHoverChangedHandler2);
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.