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 a stage
4
var stage = anychart.graphics.create("container");
5
6
// create data
7
var data = [
8
{x: "Start", value: 23},
9
{x: "Jan", value: 22},
10
{x: "Feb", value: -46},
11
{x: "Mar", value: -91},
12
{x: "Apr", value: 37},
13
{x: "May", value: -21},
14
{x: "Jun", value: 53},
15
{x: "Jul", value: 31},
16
{x: "Aug", value: -15},
17
{x: "Sep", value: 42},
18
{x: "Oct", value: 53},
19
{x: "Nov", value: -15},
20
{x: "Dec", value: 51},
21
{x: "End", isTotal: true}
22
];
23
24
// create and configure the first waterfall chart
25
var chart1 = anychart.waterfall(data);
26
chart1.title("Data Mode: Difference");
27
chart1.bounds(0, 0, "100%", "50%");
28
chart1.legend(false);
29
// set the data mode
30
chart1.dataMode("diff");
31
// set the chart container
32
chart1.container(stage);
33
// initiate drawing the chart
34
chart1.draw();
35
36
// create and configure the second waterfall chart
37
var chart2 = anychart.waterfall(data);
38
chart2.title("Data Mode: Absolute");
39
chart2.bounds(0, "50%", "100%", "50%");
40
chart2.legend(false);
41
// set the data mode
42
chart2.dataMode("absolute");
43
// set the chart container
44
chart2.container(stage);
45
// initiate drawing the chart
46
chart2.draw();
47
});