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
// Creates Heat Map
3
var chart = anychart.heatMap([
4
{x: "Rare", y: "Insignificant", heat: 0, fill: "#90caf9"},
5
{x: "Rare", y: "Minor", heat: 0, fill: "#90caf9"},
6
{x: "Rare", y: "Moderate", heat: 0, fill: "#90caf9"},
7
{x: "Rare", y: "Major", heat: 0, fill: "#90caf9"},
8
{x: "Rare", y: "Extreme", heat: 0, fill: "#90caf9"},
9
{x: "Unlikely", y: "Insignificant", heat: 0, fill: "#90caf9"},
10
{x: "Unlikely", y: "Minor", heat: 0, fill: "#90caf9"},
11
{x: "Unlikely", y: "Moderate", heat: 0, fill: "#90caf9"},
12
{x: "Unlikely", y: "Major", heat: 1, fill: "#ffb74d"},
13
{x: "Unlikely", y: "Extreme", heat: 1, fill: "#ffb74d"},
14
{x: "Possible", y: "Insignificant", heat: 0, fill: "#90caf9"},
15
{x: "Possible", y: "Minor", heat: 0, fill: "#90caf9"},
16
{x: "Possible", y: "Moderate", heat: 1, fill: "#ffb74d"},
17
{x: "Possible", y: "Major", heat: 1, fill: "#ffb74d"},
18
{x: "Possible", y: "Extreme", heat: 1, fill: "#ffb74d"},
19
{x: "Likely", y: "Insignificant", heat: 0, fill: "#90caf9"},
20
{x: "Likely", y: "Minor", heat: 1, fill: "#ffb74d"},
21
{x: "Likely", y: "Moderate", heat: 1, fill: "#ffb74d"},
22
{x: "Likely", y: "Major", heat: 2, fill: "#ef6c00"},
23
{x: "Likely", y: "Extreme", heat: 2, fill: "#ef6c00"},
24
{x: "Almost\nCertain", y: "Insignificant", heat: 0, fill: "#90caf9"},
25
{x: "Almost\nCertain", y: "Minor", heat: 1, fill: "#ffb74d"},
26
{x: "Almost\nCertain", y: "Moderate", heat: 1, fill: "#ffb74d"},
27
{x: "Almost\nCertain", y: "Major", heat: 2, fill: "#ef6c00"},
28
{x: "Almost\nCertain", y: "Extreme", heat: 3, fill: "#d84315"}
29
]);
30
31
// Sets chart settings and hover chart settings
32
chart.stroke('#fff');
33
chart.hovered()
34
.stroke('6 #fff')
35
.fill('#545f69')
36
.labels().fontColor('#fff');
37
38
// Sets selection mode for single selection
39
chart.interactivity().selectionMode("none");
40
41
// Sets adjust chart labels
42
var labels = chart.labels();
43
labels.enabled(true).minFontSize(14);
44
// variable with list of labels
45
var namesList = ["Low", "Medium", "High", "Extreme"];
46
// Formats labels
47
labels.format(function () {
48
// replace values with words for points heat
49
return namesList[this.heat];
50
});
51
52
// Sets Axes
53
chart.yAxis().stroke(null).labels().padding([0, 15, 0, 0]);
54
chart.yAxis().ticks().enabled(false);
55
56
// Sets Tooltip
57
chart.tooltip().title().useHtml(true);
58
chart.tooltip().useHtml(true)
59
.titleFormat(function () {
60
return '<b>' + namesList[this.heat] + '</b> Residual Risk';
61
})
62
.format(function () {
63
return '<span style="color: #CECECE">Likelihood: </span>' + this.x + '<br/>' +
64
'<span style="color: #CECECE">Consequence: </span>' + this.y;
65
});
66
67
// Draws Chart
68
chart.container("container");
69
chart.draw();
70
});