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 data = getData();
3
4
var chart = anychart.heatMap(data);
5
6
chart.title('Click on the chart. You have 3 clicks');
7
chart.listen('click', customListener);
8
9
var listenKey = chart.listen('click', customListener);
10
11
var counter = 3;
12
13
function customListener(e) {
14
counter--;
15
chart.title('Click on the chart. You have ' + counter + ' clicks');
16
if (counter === 0) {
17
// Removes event listener by the key
18
chart.unlistenByKey(listenKey);
19
chart.title('You have no more clicks');
20
}
21
}
22
23
chart.container('container');
24
chart.draw();
25
});
26
27
function getData() {
28
return [
29
{x: 'California', y: '2004', heat: 1704211},
30
{x: 'California', y: '2005', heat: 2782680},
31
{x: 'California', y: '2006', heat: 2992679},
32
{x: 'Illinois', y: '2004', heat: 727914},
33
{x: 'Illinois', y: '2005', heat: 1150659},
34
{x: 'Illinois', y: '2006', heat: 1134085},
35
{x: 'Massachusetts', y: '2004', heat: 238819},
36
{x: 'Massachusetts', y: '2005', heat: 157719},
37
{x: 'Massachusetts', y: '2006', heat: 887169},
38
{x: 'New York', y: '2004', heat: 1667969},
39
{x: 'New York', y: '2005', heat: 2763503},
40
{x: 'New York', y: '2006', heat: 3151022},
41
{x: 'Texas', y: '2004', heat: 219967},
42
{x: 'Texas', y: '2005', heat: 3732889},
43
{x: 'Texas', y: '2006', heat: 4185098}
44
]
45
}