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
{x: 'Meat', value: 10},
4
{x: 'Fruit', value: 12},
5
{x: 'Nuts', value: 18},
6
{x: 'Milk', value: 5},
7
{x: 'Fish', value: 9}
8
]);
9
chart.title('Click on the chart. You have 3 clicks');
10
11
chart.listen('click', customListener);
12
13
var counter = 3;
14
15
function customListener(e) {
16
counter--;
17
chart.title('Click on the chart. You have ' + counter + ' clicks');
18
if (counter === 0) {
19
// Removes event listener.
20
chart.unlisten('click', customListener);
21
chart.title('You have no more clicks');
22
}
23
}
24
25
chart.container('container');
26
chart.draw();
27
});