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
// In this page, custom style is declared in header:
6
// <style>
7
// .custom-menu
8
// { // background: '#F9FBE7'; // }
9
// </style>
10
11
var chart = anychart.line([
12
{x: 'January', value: 1},
13
{x: 'February', value: 2},
14
{x: 'March', value: 1.3},
15
{x: 'April', value: 2.9},
16
{x: 'May', value: 1.5}
17
]);
18
chart.contextMenu(false);
19
20
var customContextMenu = anychart.ui.contextMenu();
21
customContextMenu.attach(chart);
22
customContextMenu.itemsProvider(function () {
23
return [
24
{
25
text: 'Open AnyChart API',
26
href: 'https://api.anychart.com'
27
}
28
];
29
});
30
31
// Set class name.
32
customContextMenu.addClassName('custom-menu');
33
34
chart.title('Set CSS class name to Context Menu item. Right-click on the chart');
35
chart.container('container');
36
chart.draw();
37
});