HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// create sankey chart
3
var chart = anychart.sankey();
4
5
// set chart's data
6
chart.data(getData()); // eslint-disable-line no-undef
7
8
// set chart's title
9
chart.title('Website Users Flow');
10
11
// set chart's padding
12
chart.padding(10, 10, 30, 10);
13
14
// set nodes width and padding
15
chart.nodeWidth(100);
16
chart.nodePadding(30);
17
18
// Set flow's normal and hovered fill
19
chart.flow({
20
normal: {
21
fill: '#DFE0DF .3'
22
},
23
hovered: {
24
fill: '#DFE0DF .9'
25
}
26
});
27
28
// Set flow's normal and hovered fill
29
chart.node({
30
normal: {
31
fill: function () {
32
return {
33
keys: [
34
anychart.color.lighten(this.sourceColor, 0.3),
35
'.1 ' + anychart.color.lighten(this.sourceColor, 0.3),
36
'.1 #FFFFFF'
37
],
38
angle: -90
39
};
40
},
41
stroke: '#bbb'
42
},
43
hovered: {
44
fill: function () {
45
return {
46
keys: [
47
anychart.color.darken(this.sourceColor, 0.3),
48
'.1 ' + anychart.color.darken(this.sourceColor, 0.3),
49
'.1 #FFFFFF'
50
],
51
angle: -90
52
};
53
},
54
stroke: '#666'
55
}
56
});
57
58
// set container id for the chart
59
chart.container('container');
60
61
// initiate chart drawing
62
chart.draw();
63
});