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.gauges.linear([300, 250, 150]);
7
chart.addPointer(0, 1, 2);
8
9
// Get context menu.
10
var contextMenu = chart.contextMenu();
11
12
contextMenu.itemsFormatter(function (items) {
13
14
items['custom-item'] = {
15
index: 1000,
16
text: 'Custom Context Menu Item',
17
action: actionHandler
18
};
19
20
return items;
21
});
22
23
function actionHandler() {
24
alert('Custom Item Clicked');
25
}
26
27
chart.title('Get and modify context menu. Right-click on the chart');
28
chart.container('container');
29
chart.draw();
30
});