HTMLcopy
1
<label><input onclick="displayMode('drop')" type="radio" name="mode" checked>Drop</label>
2
<label><input onclick="displayMode('always-show')" type="radio" name="mode">Always Show</label>
3
<label><input onclick="displayMode('clip')" type="radio" name="mode">Clip</label>
4
<div id="container"></div>
CSScopy
16
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
label {
8
display: inline-block;
9
margin: 10px 0 0 10px;
10
}
11
#container {
12
position: absolute;
13
width: 100%;
14
top: 35px;
15
bottom: 0;
16
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
{x: "2010", y: "A", heat: 15},
6
{x: "2011", y: "A", heat: 17},
7
{x: "2012", y: "A", heat: 21},
8
{x: "2013", y: "A", heat: 23},
9
{x: "2010", y: "B", heat: 34},
10
{x: "2011", y: "B", heat: 33},
11
{x: "2012", y: "B", heat: 32},
12
{x: "2013", y: "B", heat: 30},
13
{x: "2010", y: "C", heat: 43},
14
{x: "2011", y: "C", heat: 42},
15
{x: "2012", y: "C", heat: 40},
16
{x: "2013", y: "C", heat: 38},
17
{x: "2010", y: "D", heat: 8},
18
{x: "2011", y: "D", heat: 8},
19
{x: "2012", y: "D", heat: 7},
20
{x: "2013", y: "D", heat: 8}
21
];
22
23
// create a chart and set the data
24
chart = anychart.heatMap(data);
25
26
// enable HTML for labels
27
chart.labels().useHtml(true);
28
29
// configure labels
30
chart.labels().format(function() {
31
var heat = (this.heat);
32
if (heat < 20)
33
return "<span style='font-size:22'>Low</span>";
34
if (heat < 40)
35
return "<span style='font-size:22'>Medium</span>";
36
if (heat >= 40)
37
return "<span style='font-weight:bold;font-size:22'>High</span>";
38
});
39
40
// set the chart size and title
41
chart.width(320);
42
chart.height(320);
43
chart.listen("chartDraw", function () {
44
chart.title("Heat Map: Labels\n(Display Mode = " +
45
chart.labelsDisplayMode() + ")");
46
});
47
48
// set the container id
49
chart.container("container");
50
51
// initiate drawing the chart
52
chart.draw();
53
});
54
55
// set the display mode of labels
56
function displayMode(mode) {
57
chart.labelsDisplayMode(mode);
58
}