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
var data = getData();
3
4
var chart = anychart.sunburst(data, 'as-table');
5
chart.title('Click on the chart. You have 3 clicks');
6
chart.listen('click', customListener);
7
8
var listenKey = chart.listen('click', customListener);
9
10
var counter = 3;
11
12
function customListener(e) {
13
counter--;
14
chart.title('Click on the chart. You have ' + counter + ' clicks');
15
if (counter === 0) {
16
// Removes event listener by the key
17
chart.unlistenByKey(listenKey);
18
chart.title('You have no more clicks');
19
}
20
}
21
chart.container('container');
22
chart.draw();
23
});
24
25
function getData() {
26
return [
27
{name: 'Seasonal activities', id: 'activities', parent: null, value: 1000},
28
{name: 'Winter', parent: 'activities', id: 'winter', value: 250},
29
{name: 'Spring', parent: 'activities', id: 'spring', value: 250},
30
{name: 'Summer', parent: 'activities', id: 'summer', value: 250},
31
{name: 'Autumn', parent: 'activities', id: 'autumn', value: 250},
32
{name: 'Running', parent: 'winter', id: 'run', value: 43},
33
{name: 'Snowboarding', parent: 'winter', id: 'snowboard', value: 50},
34
{name: 'Nordic Skiing', parent: 'winter', id: 'nordic', value: 50},
35
{name: 'Working Out', parent: 'winter', id: 'workout', value: 30},
36
{name: 'Ice Skating', parent: 'winter', id: 'iceskate', value: 40},
37
{name: 'Kitesurfing', parent: 'winter', id: 'kitesurf', value: 37},
38
{name: 'Riding', parent: 'spring', id: 'ride', value: 100},
39
{name: 'Crossfit', parent: 'spring', id: 'crossfit', value: 30},
40
{name: 'Hiking', parent: 'spring', id: 'hike', value: 30},
41
{name: 'Yoga', parent: 'spring', id: 'yoga', value: 40},
42
{name: 'Running', parent: 'spring', id: 'run', value: 50},
43
{name: 'Riding', parent: 'summer', id: 'ride', value: 150},
44
{name: 'Windsurfing', parent: 'summer', id: 'windsurf', value: 20},
45
{name: 'Swimming', parent: 'summer', id: 'swim', value: 30},
46
{name: 'Roller Skiing', parent: 'summer', id: 'roller', value: 10},
47
{name: 'Rowing', parent: 'summer', id: 'rowing', value: 40},
48
{name: 'Riding', parent: 'autumn', id: 'ride', value: 90},
49
{name: 'Hiking', parent: 'autumn', id: 'windsurf', value: 20},
50
{name: 'Swimming', parent: 'autumn', id: 'swim', value: 10},
51
{name: 'Nordic Skiing', parent: 'autumn', id: 'nordic', value: 40},
52
{name: 'Climbing', parent: 'autumn', id: 'climbing', value: 40}
53
];
54
}