HTMLcopy
1
<button onclick="data();">Apply changes (add points)</button>
2
<button onclick="autoRedraw();">Draw changes on the chart</button>
3
<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
var chart;
2
anychart.onDocumentReady(function () {
3
var data = getData();
4
5
chart = anychart.heatMap(data);
6
chart.title('Disable redrawing of the chart after the changes. \n Use the buttons to apply the changes and draw them');
7
chart.container('container');
8
chart.draw();
9
10
// Disable chart redrawing.
11
chart.autoRedraw(false);
12
});
13
14
function autoRedraw() {
15
16
// Enable chart redrawing.
17
chart.autoRedraw(true);
18
}
19
20
function data() {
21
var getData = chart.data();
22
var newData = getData.concat([
23
{x: 'California', y: '2007', heat: Math.round(5704211 * Math.random())},
24
{x: 'Illinois', y: '2007', heat: Math.round(527914 * Math.random())},
25
{x: 'Massachusetts', y: '2007', heat: Math.round(538819 * Math.random())},
26
{x: 'New York', y: '2007', heat: Math.round(4667969 * Math.random())},
27
{x: 'Texas', y: '2007', heat: Math.round(5185098 * Math.random())}
28
]);
29
chart.data(newData);
30
}
31
32
function getData() {
33
return [
34
{x: 'California', y: '2004', heat: 1704211},
35
{x: 'California', y: '2005', heat: 2782680},
36
{x: 'California', y: '2006', heat: 2992679},
37
{x: 'Illinois', y: '2004', heat: 727914},
38
{x: 'Illinois', y: '2005', heat: 1150659},
39
{x: 'Illinois', y: '2006', heat: 1134085},
40
{x: 'Massachusetts', y: '2004', heat: 238819},
41
{x: 'Massachusetts', y: '2005', heat: 157719},
42
{x: 'Massachusetts', y: '2006', heat: 887169},
43
{x: 'New York', y: '2004', heat: 1667969},
44
{x: 'New York', y: '2005', heat: 2763503},
45
{x: 'New York', y: '2006', heat: 3151022},
46
{x: 'Texas', y: '2004', heat: 219967},
47
{x: 'Texas', y: '2005', heat: 3732889},
48
{x: 'Texas', y: '2006', heat: 4185098}
49
]
50
}