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.column([
7
{x: 'January', value: 1},
8
{x: 'February', value: 2},
9
{x: 'March', value: 1.3},
10
{x: 'April', value: 2.9}
11
]);
12
chart.contextMenu(false);
13
14
var customContextMenu = anychart.ui.contextMenu();
15
customContextMenu.attach(chart);
16
17
// Set items provider.
18
customContextMenu.itemsProvider(function () {
19
var result = {
20
'custom-item': {
21
text: 'Open AnyChart API',
22
href: 'https://api.anychart.com',
23
index: 10
24
}
25
};
26
27
if (this.target == this.chart) {
28
result['chart-click-item'] = {
29
index: 0,
30
text: 'Context menu on Chart'
31
}
32
} else if (this.selectedPoints.length) {
33
result['point-click-item'] = {
34
index: 0,
35
text: 'Context menu on Point Name: ' + this.selectedPoints[0].getStat('categoryName')
36
}
37
}
38
39
return result;
40
});
41
42
chart.title('Set items provider function');
43
chart.container('container');
44
chart.draw();
45
});