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.scatter();
7
chart.line([
8
{x: 1, value: 0},
9
{x: 2, value: 20},
10
{x: 3, value: 10},
11
{x: 4, value: 30},
12
{x: 5, value: 20},
13
{x: 6, value: 40},
14
{x: 7, value: 30},
15
{x: 8, value: 50},
16
{x: 9, value: 40},
17
{x: 1, value: 0}
18
]);
19
20
// Get context menu.
21
var contextMenu = chart.contextMenu();
22
23
contextMenu.itemsFormatter(function (items) {
24
25
items['custom-item'] = {
26
index: 1000,
27
text: 'Custom Context Menu Item',
28
action: actionHandler
29
};
30
31
return items;
32
});
33
34
function actionHandler() {
35
alert('Custom Item Clicked');
36
}
37
38
chart.title('Get and modify context menu. Right-click on the chart');
39
chart.xGrid(true).yGrid(true);
40
chart.container('container');
41
chart.draw();
42
});