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 chart = anychart.pyramid([
3
{x: 'Physical', value: 125},
4
{x: 'Data Link', value: 135},
5
{x: 'Network', value: 125},
6
{x: 'Transport', value: 145},
7
{x: 'Session', value: 125},
8
{x: 'Presentation', value: 155},
9
{x: 'Application', value: 290}
10
]);
11
chart.title('Click on the chart. You have 3 clicks');
12
chart.listen('click', customListener);
13
14
var listenKey = chart.listen('click', customListener);
15
16
var counter = 3;
17
18
function customListener(e) {
19
counter--;
20
chart.title('Click on the chart. You have ' + counter + ' clicks');
21
if (counter === 0) {
22
// Removes event listener by the key
23
chart.unlistenByKey(listenKey);
24
chart.title('You have no more clicks');
25
}
26
}
27
28
chart.labels(false);
29
chart.container('container');
30
chart.draw();
31
});