Angular Sankey API
The Sankey is a widget that visualizes the flow magnitude between value sets. The values being connected are called nodes; the connections - links. The higher the flow magnitude, the wider the link is.
DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.
The following code shows how to create the Sankey widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.
jQuery
var data = [ { source: "Brazil", target: "Portugal", weight: 5 }, { source: "Brazil", target: "Spain", weight: 1 }, { source: "Brazil", target: "England", weight: 1 }, { source: "Canada", target: "Portugal", weight: 1 }, { source: "Canada", target: "England", weight: 1 }, { source: "Mexico", target: "Portugal", weight: 1 }, { source: "Mexico", target: "Spain", weight: 5 } ]; $(function() { $("#sankey").dxSankey({ dataSource: data }); });
<div id="sankey"></div>
Angular
<dx-sankey [dataSource]="data"> </dx-sankey>
import { DxSankeyModule } from "devextreme-angular"; // ... export class AppComponent { data: Array<{ source: string, target: string, weight: number }> = [ { source: "Brazil", target: "Portugal", weight: 5 }, { source: "Brazil", target: "Spain", weight: 1 }, { source: "Brazil", target: "England", weight: 1 }, { source: "Canada", target: "Portugal", weight: 1 }, { source: "Canada", target: "England", weight: 1 }, { source: "Mexico", target: "Portugal", weight: 1 }, { source: "Mexico", target: "Spain", weight: 5 } ]; } @NgModule({ imports: [ // ... DxSankeyModule ], // ... })
AngularJS
<div ng-controller="DemoController"> <div dx-sankey="{ dataSource: data }"></div> </div>
angular.module("DemoApp", ["dx"]) .controller("DemoController", function ($scope) { $scope.data = [ { source: "Brazil", target: "Portugal", weight: 5 }, { source: "Brazil", target: "Spain", weight: 1 }, { source: "Brazil", target: "England", weight: 1 }, { source: "Canada", target: "Portugal", weight: 1 }, { source: "Canada", target: "England", weight: 1 }, { source: "Mexico", target: "Portugal", weight: 1 }, { source: "Mexico", target: "Spain", weight: 5 } ]; });
Knockout
<div data-bind="dxSankey: { dataSource: data }"></div>
var viewModel = { data: [ { source: "Brazil", target: "Portugal", weight: 5 }, { source: "Brazil", target: "Spain", weight: 1 }, { source: "Brazil", target: "England", weight: 1 }, { source: "Canada", target: "Portugal", weight: 1 }, { source: "Canada", target: "England", weight: 1 }, { source: "Mexico", target: "Portugal", weight: 1 }, { source: "Mexico", target: "Spain", weight: 5 } ] }; ko.applyBindings(viewModel);
ASP.NET MVC Controls
@(Html.DevExtreme().Sankey() .ID("Sankey") .DataSource(new object[] { new { source = "Brazil", target = "Portugal", weight = 5 }, new { source = "Brazil", target = "Spain", weight = 1 }, new { source = "Brazil", target = "England", weight = 1 }, new { source = "Canada", target = "Portugal", weight = 1 }, new { source = "Canada", target = "England", weight = 1 }, new { source = "Mexico", target = "Portugal", weight = 1 }, new { source = "Mexico", target = "Spain", weight = 5 } }) )
@(Html.DevExtreme().Sankey() _ .ID("Sankey") _ .DataSource({ New With { .source = "Brazil", .target = "Portugal", .weight = 5 }, New With { .source = "Brazil", .target = "Spain", .weight = 1 }, New With { .source = "Brazil", .target = "England", .weight = 1 }, New With { .source = "Canada", .target = "Portugal", .weight = 1 }, New With { .source = "Canada", .target = "England", .weight = 1 }, New With { .source = "Mexico", .target = "Portugal", .weight = 1 }, New With { .source = "Mexico", .target = "Spain", .weight = 5 } }) )
See Also
Properties
This section describes options that configure the Sankey widget's contents, behavior and appearance.
Name | Description |
---|---|
adaptiveLayout |
Specifies adaptive layout options. |
alignment |
Aligns node columns vertically. |
dataSource |
Binds the widget to data. |
disabled |
Specifies whether the widget responds to the user interaction. |
elementAttr |
Specifies the attributes to be attached to the widget's root element. |
export |
Configures the exporting and printing features. |
hoverEnabled |
Specifies whether nodes and links change their style when they are hovered over or pressed. |
label |
Configures sankey nodes' labels. |
link |
Configures sankey links' appearance. |
loadingIndicator |
Configures the loading indicator. |
margin |
Generates space around the widget. |
node |
Configures sankey nodes' appearance. |
onDisposing |
A function that is executed before the widget is disposed of. |
onDrawn |
A function that is executed when the widget's rendering has finished. |
onExported |
A function that is executed after the widget is exported. |
onExporting |
A function that is executed before the widget is exported. |
onFileSaving |
A function that is executed before a file with exported widget is saved to the user's local storage. |
onIncidentOccurred |
A function that is executed when an error or warning occurs. |
onInitialized |
A function used in JavaScript frameworks to save the widget instance. |
onLinkClick |
A function that is executed when a sankey link is clicked or tapped. |
onLinkHoverChanged |
A function that is executed after the pointer enters or leaves a sankey link. |
onNodeClick |
A function that is executed when a sankey node is clicked or tapped. |
onNodeHoverChanged |
A function that is executed after the pointer enters or leaves a sankey node. |
onOptionChanged |
A function that is executed after a widget option is changed. |
palette |
Sets the palette to be used to colorize sankey nodes. |
paletteExtensionMode |
Specifies how to extend the palette when it contains less colors than the number of sankey nodes. |
pathModified |
Notifies the widget that it is embedded into an HTML page that uses a tag modifying the path. |
redrawOnResize |
Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates. |
rtlEnabled |
Switches the widget to a right-to-left representation. |
size |
Specifies the widget's size in pixels. |
sortData |
Specifies nodes' sorting order in their columns. |
sourceField |
Specifies which data source field provides links' source nodes. |
targetField |
Specifies which data source field provides links' target nodes. |
theme |
Sets the name of the theme the widget uses. |
title |
Configures the widget's title. |
tooltip |
Configures tooltips - small pop-up rectangles that display information about a data-visualizing widget element being pressed or hovered over with the mouse pointer. |
weightField |
Specifies which data source field provides links' weights. |
Methods
Name | Description |
---|---|
beginUpdate() |
Prevents the widget from refreshing until the endUpdate() method is called. |
dispose() |
Disposes of all the resources allocated to the Sankey instance. |
element() |
Gets the root widget element. |
endUpdate() |
Refreshes the widget after a call of the beginUpdate() method. |
exportTo(fileName, format) |
Exports the widget. |
getAllLinks() |
Gets all sankey links. |
getAllNodes() |
Gets all sankey nodes. |
getDataSource() |
Gets the DataSource instance. |
getInstance(element) |
Gets the instance of a widget found using its DOM node. |
getSize() |
Gets the current widget size. |
hideLoadingIndicator() |
Hides the loading indicator. |
hideTooltip() |
Hides all widget tooltips. |
instance() |
Gets the widget's instance. Use it to access other methods of the widget. |
off(eventName) |
Detaches all event handlers from a single event. |
off(eventName, eventHandler) |
Detaches a particular event handler from a single event. |
on(eventName, eventHandler) |
Subscribes to an event. |
on(events) |
Subscribes to events. |
option() |
Gets all widget options. |
option(optionName) |
Gets the value of a single option. |
option(optionName, optionValue) |
Updates the value of a single option. |
option(options) |
Updates the values of several options. |
print() |
Opens the browser's print window. |
render() |
Redraws the widget. |
showLoadingIndicator() |
Shows the loading indicator. |
svg() |
Gets the widget's SVG markup. |
Events
Name | Description |
---|---|
disposing |
Raised before the widget is disposed of. |
drawn |
Raised when the widget's rendering has finished. |
exported |
Raised after the widget is exported. |
exporting |
Raised before the widget is exported. |
fileSaving |
Raised before a file with exported widget is saved to the user's local storage. |
incidentOccurred |
Raised when an error or warning occurs. |
initialized |
Raised only once, after the widget is initialized. |
linkClick |
Raised when a sankey link is clicked or tapped. |
linkHoverChanged |
Raised after the pointer enters or leaves a sankey link. |
nodeClick |
Raised when a sankey node is clicked or tapped. |
nodeHoverChanged |
Raised after the pointer enters or leaves a sankey node. |
optionChanged |
Raised after a widget option is changed. |
Node
You can use the getAllNodes() method and event handlers to access nodes, for example, onNodeClick.
Link
You can access links using the getAllLinks() method and within some event handlers, for example, onLinkClick.
If you have technical questions, please create a support ticket in the DevExpress Support Center.