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
3
// create data set
4
var dataSet = anychart.data.set([
5
{x: "January", y: "Desktop", heat: 24},
6
{x: "January", y: "Mobile", heat: 27},
7
{x: "January", y: "Web", heat: 49},
8
{x: "February", y: "Desktop", heat: 25},
9
{x: "February", y: "Mobile", heat: 27},
10
{x: "February", y: "Web", heat: 48},
11
{x: "March", y: "Desktop", heat: 25},
12
{x: "March", y: "Mobile", heat: 28},
13
{x: "March", y: "Web", heat: 47},
14
{x: "April", y: "Desktop", heat: 26},
15
{x: "April", y: "Mobile", heat: 28},
16
{x: "April", y: "Web", heat: 46},
17
{x: "May", y: "Desktop", heat: 33},
18
{x: "May", y: "Mobile", heat: 24},
19
{x: "May", y: "Web", heat: 43},
20
{x: "June", y: "Desktop", heat: 32},
21
{x: "June", y: "Mobile", heat: 24},
22
{x: "June", y: "Web", heat: 44},
23
{x: "July", y: "Desktop", heat: 28},
24
{x: "July", y: "Mobile", heat: 27},
25
{x: "July", y: "Web", heat: 45},
26
{x: "August", y: "Desktop", heat: 30},
27
{x: "August", y: "Mobile", heat: 22},
28
{x: "August", y: "Web", heat: 48},
29
{x: "September", y: "Desktop", heat: 28},
30
{x: "September", y: "Mobile", heat: 24},
31
{x: "September", y: "Web", heat: 48},
32
{x: "October", y: "Desktop", heat: 29},
33
{x: "October", y: "Mobile", heat: 25},
34
{x: "October", y: "Web", heat: 47},
35
{x: "November", y: "Desktop", heat: 28},
36
{x: "November", y: "Mobile", heat: 23},
37
{x: "November", y: "Web", heat: 49},
38
{x: "December", y: "Desktop", heat: 22},
39
{x: "December", y: "Mobile", heat: 30},
40
{x: "December", y: "Web", heat: 48}
41
]);
42
43
// create chart
44
var chart = anychart.heatMap(dataSet);
45
chart.title("Email Opens by Environment 2014");
46
47
var tooltip = chart.tooltip();
48
var title = tooltip.title();
49
title.hAlign("center");
50
tooltip.titleFormat("{%y}");
51
tooltip.format(function(){
52
return "Month: " + this.x + "\nOpens: " + this.heat + "%";
53
});
54
55
// format labels
56
var labels = chart.labels();
57
labels.enabled(true);
58
59
labels.format("{%heat}%");
60
61
var xLabels = chart.xAxis().labels();
62
xLabels.format(function(){
63
return (this.value).substr(0, 3);
64
});
65
66
// draw chart
67
chart.container("container");
68
chart.draw();
69
});