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 a chart
4
var chart = anychart.heatMap(getData());
5
6
// enable scrollers
7
chart.yScroller(true);
8
chart.xScroller(true);
9
10
// set scrollers orientation
11
chart.xScroller().orientation("top");
12
chart.yScroller().orientation("left");
13
14
// create ordinalColor scale
15
var colorScale = anychart.scales.ordinalColor();
16
17
// set range of heat parameter's values and corresponding colors
18
colorScale.ranges([
19
{less: 7, color: "#33CC33"},
20
{from: 7, to: 22, color: "#CCFF66"},
21
{from: 22, to: 32, color: "#EB9E33"},
22
{greater: 32, color: "#FF3300"}
23
]);
24
25
// apply colorScale for colorizing heatMap chart
26
chart.colorScale(colorScale);
27
28
// display the chart
29
chart.container("container");
30
chart.draw();
31
});
32
33
// get data function
34
function getData(){
35
return [
36
{y: "Part 1", x: "Mobile", heat: 15},
37
{y: "Part 2", x: "Mobile", heat: 17},
38
{y: "Part 3", x: "Mobile", heat: 21},
39
{y: "Part 4", x: "Mobile", heat: 23},
40
{y: "Part 5", x: "Mobile", heat: 20},
41
{y: "Part 6", x: "Mobile", heat: 33},
42
{y: "Part 7", x: "Mobile", heat: 19},
43
{y: "Part 1", x: "WebMail", heat: 34},
44
{y: "Part 2", x: "WebMail", heat: 33},
45
{y: "Part 3", x: "WebMail", heat: 32},
46
{y: "Part 4", x: "WebMail", heat: 30},
47
{y: "Part 5", x: "WebMail", heat: 20},
48
{y: "Part 6", x: "WebMail", heat: 7},
49
{y: "Part 7", x: "WebMail", heat: 21},
50
{y: "Part 1", x: "Desktop", heat: 43},
51
{y: "Part 2", x: "Desktop", heat: 42},
52
{y: "Part 3", x: "Desktop", heat: 40},
53
{y: "Part 4", x: "Desktop", heat: 38},
54
{y: "Part 5", x: "Desktop", heat: 24},
55
{y: "Part 6", x: "Desktop", heat: 36},
56
{y: "Part 7", x: "Desktop", heat: 23},
57
{y: "Part 1", x: "Undetected", heat: 6},
58
{y: "Part 2", x: "Undetected", heat: 8},
59
{y: "Part 3", x: "Undetected", heat: 7},
60
{y: "Part 4", x: "Undetected", heat: 8},
61
{y: "Part 5", x: "Undetected", heat: 15},
62
{y: "Part 6", x: "Undetected", heat: 4},
63
{y: "Part 7", x: "Undetected", heat: 9}
64
];
65
}