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