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
3
// create a chart
4
var chart = anychart.column();
5
6
// set chart data
7
chart.data([
8
["John" , 10000, 12000],
9
["Jake" , 12000, 15000],
10
["Peter", 18000, 16000],
11
["James", 11000, 13000],
12
["Mary", 9000, 19000]
13
]);
14
15
16
// replace menu items provider
17
chart.contextMenu().itemsProvider(function() {
18
var items = {
19
'menu-item-1': {
20
'text': 'Print chart',
21
'action': function() {
22
this.chart.print();
23
}
24
},
25
'menu-item-2': {
26
'text': 'Save chart as image',
27
'action': function() {
28
this.chart.saveAsPng();
29
}
30
},
31
'menu-item-3': {
32
'text': 'Go to my page',
33
'href': 'http://docs.anychart.com',
34
'target': '_blank'
35
}
36
}
37
38
return items;
39
});;
40
41
42
// set title
43
chart.title("Basic Custom Context Menu");
44
45
// draw
46
chart.container("container");
47
chart.draw();
48
});