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
var chart = anychart.pyramid([
3
{x: 'Physical', value: 125},
4
{x: 'Data Link', value: 135},
5
{x: 'Network', value: 125},
6
{x: 'Transport', value: 145},
7
{x: 'Session', value: 125},
8
{x: 'Presentation', value: 155},
9
{x: 'Application', value: 290}
10
]);
11
12
// To change the way how context menu looks you need to change CSS.
13
// By default CSS from AnyChart CDN is used: https://cdn.anychart.com/releases/8.13.0/css/anychart-ui.min.css
14
// Download it, alter, upload to your server and link from your pages to change the look.
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.labels(false);
36
chart.container('container');
37
chart.draw();
38
39
});