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
// set stage
4
var stage = anychart.graphics.create("container");
5
6
//chart
7
8
// set data
9
var data = anychart.data.set([
10
['FULL PROGRAM FORECAST', 228, 53]
11
]);
12
13
// map the data
14
var seriesData1_1 = data.mapAs({x: 0, value: 1});
15
var seriesData1_2 = data.mapAs({x: 0, value: 2});
16
17
// set chart
18
var chart = anychart.column();
19
20
// create waterfall series
21
chart.column()
22
.data(seriesData1_1)
23
.name('Application processing costs')
24
.fill('#032e50')
25
.normal()
26
.stroke('#032e50');
27
28
// create waterfall series
29
chart.column()
30
.data(seriesData1_2)
31
.name('Refunds')
32
.fill('#d99c61')
33
.normal()
34
.stroke('#d99c61');
35
36
var scale = chart.yScale();
37
// Set scale maximum.
38
scale.maximum(400);
39
40
scale.stackMode("value");
41
// Set the stacking direction
42
scale.stackDirection("reverse")
43
44
// set labels settings
45
chart.labels()
46
.enabled(true)
47
.fontColor('#fff')
48
.position('center');
49
50
// set legend settings
51
chart.legend().enabled(false);
52
53
// set line markers
54
var lineMarker = chart.lineMarker(0);
55
lineMarker.value(281);
56
lineMarker.stroke({
57
// set stroke thickness
58
thickness: 2,
59
// set stroke color
60
color: "#1388ca",
61
});
62
63
var lineMarker2 = chart.lineMarker(1);
64
lineMarker2.value(362);
65
lineMarker2.stroke({
66
// set stroke thickness
67
thickness: 2,
68
// set stroke color
69
color: "#1388ca",
70
});
71
72
// chart size and position
73
chart.bounds(0, 0, "30%", "100%");
74
75
// draw
76
chart.container(stage);
77
chart.draw();
78
79
var label2 = anychart.standalones.label();
80
81
// Set label text.
82
label2.text("$81M");
83
label2.offsetX(100);
84
label2.offsetY(120);
85
label2.fontColor("#1388ca");
86
87
label2.container(stage);
88
label2.draw();
89
90
//chart 2
91
92
// set data
93
var data2 = anychart.data.set([
94
['FY12-17 ACTUAL', 198, 42],
95
['FY18 FORECAST', 11, 2],
96
['FY19 FORECAST', 9, 4],
97
['FY20 & BEYOND FORECAST', 10, 5]
98
]);
99
100
// map the data
101
var seriesData2_1 = data2.mapAs({x: 0, value: 1});
102
var seriesData2_2 = data2.mapAs({x: 0, value: 2});
103
104
// create a waterfall chart
105
var chart2 = anychart.waterfall();
106
107
// create waterfall series
108
chart2.waterfall()
109
.data(seriesData2_1)
110
.name('Application processing costs')
111
.fill('#547287')
112
.risingFill('#547287')
113
.fallingFill('#547287')
114
.normal()
115
.stroke('#547287')
116
.risingStroke('#547287')
117
.fallingStroke('#547287');
118
119
// create waterfall series
120
chart2.waterfall()
121
.data(seriesData2_2)
122
.name('Refunds')
123
.fill('#d99c61')
124
.risingFill('#d99c61')
125
.fallingFill('#d99c61')
126
.normal()
127
.stroke('#d99c61')
128
.risingStroke('#d99c61')
129
.fallingStroke('#d99c61');
130
131
var scale2 = chart2.yScale();
132
// Set scale maximum.
133
scale2.maximum(400);
134
135
// set labels settings
136
chart2.labels()
137
.enabled(true)
138
.fontColor('#fff')
139
.position('center');
140
141
// set legend settings
142
chart2.legend()
143
.enabled(true)
144
.itemsSourceMode('default')
145
.itemsLayout("vertical-expandable")
146
.position("bottom")
147
.align("right")
148
.positionMode("inside")
149
.itemsFormatter(function(items){
150
// push into items array
151
items.push({
152
// set text of a new item
153
text: "Remaining funds for unexpected expenses",
154
iconFill: "#1388ca"
155
},
156
{
157
// set text of a new item
158
text: "Cumulative costs",
159
iconStroke: "#ad431c",
160
iconType: "line"
161
});
162
// return items array
163
return items;
164
});
165
166
// configure connectors
167
chart2.connectorStroke("#ad431c", 2, "2");
168
169
// set line marker
170
var lineMarker3 = chart2.lineMarker();
171
lineMarker3.value(362);
172
lineMarker3.stroke({
173
// set stroke thickness
174
thickness: 2,
175
// set stroke color
176
color: "#ad431c",
177
// set dashes and gaps
178
dash: "2 4"
179
});
180
181
// make labels smaller
182
chart2.xAxis().labels().fontSize(8);
183
184
// disable yAxis
185
chart2.yAxis().enabled(false);
186
187
// chart size and position
188
chart2.bounds("30%", 0, "70%", "100%");
189
190
// draw
191
chart2.container(stage);
192
chart2.draw();
193
194
var label = anychart.standalones.label();
195
196
// Set label text.
197
label.text("Application fees collected $362M");
198
label.offsetX(280);
199
label.offsetY(50);
200
label.fontColor("#ad431c");
201
202
label.container(stage);
203
label.draw();
204
});