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