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