HTMLcopy
1
<button id="btn">Update</button>
2
<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
{x: "Start", value: 23},
6
{x: "Jan", value: 22},
7
{x: "Feb", value: -46},
8
{x: "Mar", value: -91},
9
{x: "Apr", value: 37},
10
{x: "May", value: -21},
11
{x: "Jun", value: 53},
12
{x: "Jul", value: 31},
13
{x: "Aug", value: -15},
14
{x: "Sep", value: 42},
15
{x: "Oct", value: 53},
16
{x: "Nov", value: -15},
17
{x: "Dec", value: 51},
18
{x: "End", isTotal: true}
19
];
20
21
// create a waterfall chart
22
var chart = anychart.waterfall();
23
24
// create a series and set the data
25
var series = chart.waterfall(data);
26
27
// set the chart title
28
chart.title("Waterfall Chart: Basic Sample");
29
30
// set the container id
31
chart.container("container");
32
33
// initiate drawing the chart
34
chart.draw();
35
36
var btn = document.getElementById('btn');
37
btn.addEventListener('click', function() {
38
var newData = [
39
{x: "Start", value: 13},
40
{x: "Jan", value: 28},
41
{x: "Feb", value: -26},
42
{x: "Mar", value: 18},
43
{x: "Apr", value: 17},
44
{x: "May", value: -21},
45
{x: "Jun", value: 13},
46
{x: "Jul", value: 31},
47
{x: "Aug", value: 15},
48
{x: "Sep", value: -42},
49
{x: "Oct", value: 53},
50
{x: "Nov", value: -15},
51
{x: "Dec", value: 51},
52
{x: "End", isTotal: true}
53
];
54
55
chart.data(newData);
56
});
57
});