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 curve factor for the flow
9
chart.curveFactor(0);
10
11
// set chart's palette
12
chart.palette([
13
'#47659b',
14
'#355691',
15
'#314f84',
16
'#2c4777',
17
'#273f6a',
18
'#22375d',
19
'#1d2f50',
20
'#192842',
21
'#1d2f50',
22
'#22375d',
23
'#273f6a',
24
'#2c4777',
25
'#314f84',
26
'#355691',
27
'#47659b'
28
]);
29
30
// // set nodes width and padding
31
chart.nodeWidth(200);
32
33
// set node's label font color and weight
34
chart.node().normal().labels().fontColor('#fff').fontWeight('bold');
35
36
// disable tooltips for thew node
37
chart.node().tooltip().enabled(false);
38
39
// disable tooltip and label in hovered state for the flow
40
chart.flow().tooltip().enabled(false);
41
chart.flow().hovered().labels().enabled(false);
42
43
// set flow's normal and hovered fill
44
chart.flow({
45
normal: {
46
fill: function () {
47
return this.sourceColor + ' ' + 0.3;
48
}
49
},
50
hovered: {
51
fill: function () {
52
return this.sourceColor + ' ' + 0.9;
53
}
54
}
55
});
56
57
// set container id for the chart
58
chart.container('container');
59
60
// initiate chart drawing
61
chart.draw();
62
});