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: "Solar Energy", to: "Shading", weight: 10},
6
{from: "Shading", to: null, weight: 6},
7
{from: "Shading", to: "Facade", weight: 4},
8
{from: "Facade", to: null, weight: 3},
9
{from: "Facade", to: "Interior", weight: 1}
10
];
11
12
// create a chart and set the data
13
var chart = anychart.sankey(data);
14
15
// set the width of nodes
16
chart.nodeWidth("50%");
17
18
// set the chart title
19
chart.title("Sankey Diagram: Dropoffs");
20
21
// set the container id
22
chart.container("container");
23
24
// initiate drawing the chart
25
chart.draw();
26
});