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.scatter();
3
chart.line([
4
{x: 1, value: 0},
5
{x: 2, value: 20},
6
{x: 3, value: 10},
7
{x: 4, value: 30},
8
{x: 5, value: 20},
9
{x: 6, value: 40},
10
{x: 7, value: 30},
11
{x: 8, value: 50},
12
{x: 9, value: 40},
13
{x: 1, value: 0}
14
]);
15
chart.title('Click on the chart. You have 3 clicks');
16
17
chart.listen('click', customListener);
18
19
var counter = 3;
20
21
function customListener(e) {
22
counter--;
23
chart.title('Click on the chart. You have ' + counter + ' clicks');
24
if (counter === 0) {
25
// Removes event listener.
26
chart.unlisten('click', customListener);
27
chart.title('You have no more clicks');
28
}
29
}
30
31
chart.xGrid(true).yGrid(true);
32
chart.container('container');
33
chart.draw();
34
});