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([
7
{x: "January", value: 1},
8
{x: "February", value: 2},
9
{x: "March", value: 1.3},
10
{x: "April", value: 2.9}
11
]);
12
13
chart.contextMenu().itemsFormatter(function () {
14
15
// Adding custom item to the top of context menu.
16
this.unshift({
17
text: "My custom item 1",
18
subMenu: [{
19
text: "My custom sub-item 1",
20
href: "https://anychart.com"
21
}]
22
});
23
24
// Adding separator after custom item 1.
25
this.splice(1, 0, undefined);
26
27
// Adding custom item to the bottom of context menu.
28
this.push({
29
text: "My custom item 2",
30
subMenu: [{
31
text: "My custom sub-item 2",
32
href: "https://anychart.com"
33
}]
34
});
35
return this;
36
});
37
38
chart.title("Use items formatter to add submenu");
39
chart.container("container");
40
chart.draw();
41
});