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 data = getData();
7
8
var chart = anychart.tagCloud(data);
9
10
// Get context menu.
11
var contextMenu = chart.contextMenu();
12
13
contextMenu.itemsFormatter(function (items) {
14
15
items['custom-item'] = {
16
index: 1000,
17
text: 'Custom Context Menu Item',
18
action: actionHandler
19
};
20
21
return items;
22
});
23
24
function actionHandler() {
25
alert('Custom Item Clicked');
26
}
27
28
chart.title('Get and modify context menu. Right-click on the chart');
29
chart.container('container');
30
chart.draw();
31
});
32
33
function getData() {
34
return [
35
{x: 'learning', value: 80},
36
{x: 'lists', value: 44},
37
{x: 'meaning', value: 40},
38
{x: 'useful', value: 36},
39
{x: 'different', value: 32},
40
{x: 'grammar', value: 28},
41
{x: 'teaching', value: 24},
42
{x: 'example', value: 20},
43
{x: 'includes', value: 56},
44
{x: 'thing', value: 12},
45
{x: 'vocabulary', value: 10},
46
{x: 'frequency', value: 10},
47
{x: 'phrases', value: 15},
48
{x: 'content', value: 27}
49
]
50
}