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
chart.title('Click on the chart. You have 3 clicks');
6
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
15
chart.unlisten('click', customListener);
16
chart.title('You have no more clicks');
17
}
18
}
19
20
chart.container('container');
21
chart.draw();
22
});
23
24
function getData() {
25
return [
26
{x: 'California', y: '2004', heat: 1704211},
27
{x: 'California', y: '2005', heat: 2782680},
28
{x: 'California', y: '2006', heat: 2992679},
29
{x: 'Illinois', y: '2004', heat: 727914},
30
{x: 'Illinois', y: '2005', heat: 1150659},
31
{x: 'Illinois', y: '2006', heat: 1134085},
32
{x: 'Massachusetts', y: '2004', heat: 238819},
33
{x: 'Massachusetts', y: '2005', heat: 157719},
34
{x: 'Massachusetts', y: '2006', heat: 887169},
35
{x: 'New York', y: '2004', heat: 1667969},
36
{x: 'New York', y: '2005', heat: 2763503},
37
{x: 'New York', y: '2006', heat: 3151022},
38
{x: 'Texas', y: '2004', heat: 219967},
39
{x: 'Texas', y: '2005', heat: 3732889},
40
{x: 'Texas', y: '2006', heat: 4185098}
41
]
42
}