HTMLcopy
1
<button onclick="label();">Apply changes (add labels)</button>
2
<button onclick="autoRedraw();">Draw changes on the chart</button>
3
<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
var chart;
2
anychart.onDocumentReady(function () {
3
chart = anychart.waterfall([
4
{x: 'Net Sales', value: 5085000},
5
{x: 'Cost of Sales', value: -1250450},
6
{x: 'Gross Income', isTotal: true},
7
{x: 'Operating Expenses', value: -2350050},
8
{x: 'Operating Income', isTotal: true},
9
{x: 'Other Income', value: 750000},
10
{x: 'Extraordinary Gain', value: -230050}
11
]);
12
chart.title('Disable redrawing of the chart after the changes. \n Use the buttons to apply the changes and draw them');
13
chart.margin().left('10%');
14
chart.container('container');
15
chart.draw();
16
17
// Disable chart redrawing.
18
chart.autoRedraw(false);
19
});
20
21
function autoRedraw() {
22
23
// Enable chart redrawing.
24
chart.autoRedraw(true);
25
}
26
27
var counter = 0;
28
29
function label() {
30
chart.label(counter++, {enabled: true, offsetY: 10 * counter++, fontWeight: 600, fontColor: 'rgba(' + Math.floor(Math.random() * 130).toString(10) + ','
31
+ Math.floor(Math.random() * 140).toString(10) + ','
32
+ Math.floor(Math.random() * 150).toString(10) + ')'});
33
}