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
// To change the way how context menu looks you need to change CSS.
3
// By default CSS from AnyChart CDN is used: https://cdn.anychart.com/releases/8.13.0/css/anychart-ui.min.css
4
// Download it, alter, upload to your server and link from your pages to change the look.
5
6
var chart = anychart.waterfall([
7
{x: 'Net Sales', value: 5085000},
8
{x: 'Cost of Sales', value: -1250450},
9
{x: 'Gross Income', isTotal: true},
10
{x: 'Operating Expenses', value: -2350050},
11
{x: 'Operating Income', isTotal: true},
12
{x: 'Other Income', value: 750000},
13
{x: 'Extraordinary Gain', value: -230050}
14
]);
15
16
// Get context menu.
17
var contextMenu = chart.contextMenu();
18
19
contextMenu.itemsFormatter(function (items) {
20
21
items['custom-item'] = {
22
index: 1000,
23
text: 'Custom Context Menu Item',
24
action: actionHandler
25
};
26
27
return items;
28
});
29
30
function actionHandler() {
31
alert('Custom Item Clicked');
32
}
33
34
chart.title('Get and modify context menu. Right-click on the chart');
35
chart.container('container');
36
chart.draw();
37
});