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
// configure the visual settings of nodes
19
chart.node().normal().fill("#64b5f6 0.5");
20
chart.node().hovered().fill(anychart.color.darken("#64b5f6"));
21
chart.node().normal().stroke("#455a64", 2);
22
23
// configure the visual settings of flows
24
chart.flow().normal().fill("#ffa000 0.4");
25
chart.flow().hovered().fill(anychart.color.darken("#ffa000"));
26
chart.flow().hovered().stroke("#455a64");
27
28
// configure the visual settings of dropoffs
29
chart.dropoff().normal().fill(
30
{keys: ["#dd2c00 0.4", "#455a64 0.7"], angle: 270}
31
);
32
chart.dropoff().hovered().stroke("#455a64");
33
34
// set the chart title
35
chart.title("Sankey Diagram: Appearance");
36
37
// set the container id
38
chart.container("container");
39
40
// initiate drawing the chart
41
chart.draw();
42
});