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
// add items
16
chart.contextMenu().itemsFormatter(function(items){
17
console.log(items);
18
// starting index
19
index = items['full-screen-enter'].index;
20
21
// add item with custom action
22
items['my-item'] ={
23
'text': 'Custom item with alert action',
24
'action': function() {
25
alert('Custom action');
26
},
27
'index': index + 0.01
28
};
29
30
// add item with custom url
31
items['my-url'] = {
32
'text': 'Go to AnyChart Blog',
33
'href': 'https://anychart.com/blog/',
34
'index': index + 0.02
35
};
36
37
return items;
38
});
39
40
// set title
41
chart.title("Context Menu: Items Text Changed");
42
43
// draw
44
chart.container("container");
45
chart.draw();
46
});