SankeyDiagramData
New in version 5.0.10
SankeyDiagramData ( inputFormat ; data1 ; data2 ; . . . ; data1000 )
Argument | Type | Range | Default | Note |
---|---|---|---|---|
inputFormat | int | 1..3 | (required) | |
data1 | str | (required) | ||
data2 | str | (required) | ||
... | str | (required) | ||
data1000 | str | (required) |
Examples
SankeyDiagramData(1;"A" 2 0 0 1 5 0 0 0 1;"B" 2 1 0 2 0 0 0 0 0;...)
SankeyDiagramData(2;"A" "B" 3.85;"A" "Z" 1.25;...)
SankeyDiagramData(3;"A" "B" "C" "D";0 1 3.85;0 2 1.25;1 3 1.55;...)
Description
Data for Sankey diagrams can be passed over to xmCHART by using the function SankeyDiagramData(). Three input formats are available for this. The input format can be controlled by using the 1st argument inputFormat.
inputFormat = 1:
This input format is limited to 2-layered Sankey diagrams, i.e. diagrams with only 2 columns. The data is arranged in matrix form with each row representing a node and its outgoing links. Using inputFormat = 1 proves to be advantageous when source and target layers are referring to the same node IDs — no circular link error is thrown.
| SANKEY_DIAGRAM_DATA_01 |
1 | OpenDrawing(400;400) |
2 | SankeyDiagram(label) /* Function SankeyDiagram(...) is always listed first. */ |
3 | |
4 | "Africa" 314 0 211 0 54 16 0 0 0 67; |
5 | "East Asia" 0 163 60 0 97 33 0 38 0 87; |
6 | "Europe" 0 0 240 0 0 0 0 0 0 0; |
7 | "Latin America" 0 0 176 88 363 0 0 0 0 0; |
8 | "North America" 0 0 122 28 0 0 0 0 0 0; |
9 | "Oceania" 0 0 17 0 0 19 0 0 0 0; |
10 | "South Asia" 0 53 139 0 151 35 131 0 0 490; |
11 | "South East Asia" 0 15 47 0 106 28 0 78 0 0; |
12 | "Soviet Union" 0 0 61 0 0 0 0 0 187 0; |
13 | "West Asia" 0 0 45 0 17 0 0 0 0 93) |
14 | SankeyDiagramLinkColorScheme(3;0.25) |
15 | |
16 | SankeyDiagramNodeLabel(;auto;"{NODE_ID}") |
17 |
inputFormat = 2:
The data is arranged in a series of link definitions separated by a semicolon ";". Each link is defined by 3 values, i.e. the source ID of the link, the target ID of the link and the link value (weight). Important: Avoid cycles in your data, e.g. if A links to itself, or A links to B which links to C which links to A you will get a "Circular link error".
| SANKEY_DIAGRAM_DATA_02 |
1 | OpenDrawing(300;200) |
2 | SankeyDiagram(label;16;3;1%) /* Function SankeyDiagram(...) is always listed first. */ |
3 | SankeyDiagramData(2;"A" "X" 5; "A" "Y" 7; "A" "Z" 6; "B" "X" 2; "B" "Y" 9; "B" "Z" 4) |
4 | SankeyDiagramNodeStyle(;darkRed) |
5 | SankeyDiagramNodeLabel(;auto;"{NODE_ID}") |
6 |
inputFormat = 3:
A list of all node IDs is entered as the 2nd argument in the SankeyDiagramData() function. The following 3rd, 4th,... arguments contain the link definitions. Each link is defined by 3 values, i.e. the index of the source node ID, the index of the target node ID and the link value (weight). Please note that indices start at 0. Important: Avoid cycles in your data, e.g. if A links to itself, or A links to B which links to C which links to A you will get a "Circular link error".
| SANKEY_DIAGRAM_DATA_03 |
1 | OpenDrawing(300;200) |
2 | SankeyDiagram(label;16;3;1%) /* Function SankeyDiagram(...) is always listed first. */ |
3 | SankeyDiagramData(3;"A" "B" "X" "Y" "Z"; 0 2 5; 0 3 7; 0 4 6; 1 2 2; 1 3 9; 1 4 4) |
4 | SankeyDiagramNodeStyle(;darkRed) |
5 | SankeyDiagramNodeLabel(;auto;"{NODE_ID}") |
6 |
Please note that SankeyDiagramData() should be listed after function SankeyDiagram() . This rule generally applies: Function SankeyDiagram() should always be listed first before other Sankey functions are called.