HTMLcopy
1
<button onclick="show()">Show context menu</button>
2
<button onclick="hide()">Hide context menu</button>
3
<div id="container"></div>
CSScopy
9
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
JavaScriptcopy
x
1
var chart;
2
var customContextMenu;
3
anychart.onDocumentReady(function () {
4
// To change the way how context menu looks you need to change CSS.
5
// By default CSS from AnyChart CDN is used: https://cdn.anychart.com/releases/8.13.0/css/anychart-ui.min.css
6
// Download it, alter, upload to your server and link from your pages to change the look.
7
8
chart = anychart.line([
9
{x: 'January', value: 1},
10
{x: 'February', value: 2},
11
{x: 'March', value: 1.3},
12
{x: 'April', value: 2.9}
13
]);
14
chart.contextMenu(false);
15
chart.bounds(0, 5, '100%', '90%');
16
17
customContextMenu = anychart.ui.contextMenu();
18
19
customContextMenu.attach(chart);
20
customContextMenu.items([
21
{
22
text: 'Open AnyChart API',
23
href: 'https://api.anychart.com'
24
}
25
]);
26
27
chart.title('Show and hide context menu');
28
chart.container('container');
29
chart.draw();
30
});
31
32
function show() {
33
34
// Show context menu.
35
customContextMenu.show(150, 150);
36
}
37
38
function hide() {
39
40
// Hide context menu.
41
customContextMenu.hide();
42
}