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/css/7.14.3/anychart-ui.css
4
// Download it, alter, upload to your server and link from your pages to change the look.
5
6
var chart = anychart.line([1, 2, 1.3, 2.9]);
7
chart.contextMenu(false);
8
9
var customContextMenu = anychart.ui.contextMenu();
10
11
customContextMenu.attach(chart);
12
customContextMenu.itemsProvider(function () {
13
return [
14
{
15
text: "Open AnyChart API",
16
eventType: "customEvent"
17
}
18
];
19
});
20
21
customContextMenu.listen("customEvent", customListener);
22
23
function customListener(e) {
24
return chart.title("Event listener for the context menu.")
25
}
26
27
// Remove event listener.
28
customContextMenu.unlisten("customEvent", customListener);
29
30
chart.container("container");
31
chart.draw();
32
});