JavaScript/jQuery Sankey - Show and Hide a Tooltip
Tooltips can be invoked programmatically by calling a Node or Link object's showTooltip() method. You can access these objects with API methods or in event handlers, such as onNodeClick and onLinkClick, onNodeHoverChanged and onLinkHoverChanged. The event handlers are demonstrated in the following code. To hide the tooltip, call the UI component instance's hideTooltip() method.
JavaScript
- $(function() {
- $("#sankeyContainer").dxSankey({
- // ...
- tooltip: { enabled: false },
- // Shows the tooltip only when a sankey link is clicked
- onLinkClick: function(e) {
- e.target.showTooltip();
- },
- // Hides the tooltip when the sankey link is no longer hovered over or pressed
- onLinkHoverChanged: function(e) {
- if (!e.target.isHovered()) {
- e.component.hideTooltip();
- }
- }
- });
- });