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.gauges.linear([300, 250, 150]);
3
chart.addPointer(0, 1, 2);
4
chart.title('Click on the chart. You have 3 clicks');
5
chart.listen('click', customListener);
6
7
var listenKey = chart.listen('click', customListener);
8
9
var counter = 3;
10
11
function customListener(e) {
12
counter--;
13
chart.title('Click on the chart. You have ' + counter + ' clicks');
14
if (counter === 0) {
15
// Removes event listener by the key
16
chart.unlistenByKey(listenKey);
17
chart.title('You have no more clicks');
18
}
19
}
20
21
22
chart.container('container');
23
chart.draw();
24
});