HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
{from: "Canada", to: "France", weight: 2230000},
6
{from: "Canada", to: "Germany", weight: 1990000},
7
{from: "Canada", to: "Italy", weight: 1180000},
8
{from: "Canada", to: "Spain", weight: 990000},
9
{from: "USA", to: "France", weight: 950000},
10
{from: "USA", to: "Germany", weight: 2020000},
11
{from: "USA", to: "Spain", weight: 1110000}
12
];
13
14
// create a chart and set the data
15
var chart = anychart.sankey(data);
16
17
// set the width of nodes
18
chart.nodeWidth("30%");
19
20
// set the chart title
21
chart.title("Sankey Diagram: Basic Sample");
22
23
// set the container id
24
chart.container("container");
25
26
// initiate drawing the chart
27
chart.draw();
28
});