HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// The data used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/samples/heat-map-charts/heat-map-in-poker/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/heat-map-charts/heat-map-in-poker/data.json',
6
function (data) {
7
// create Heat Map Chart
8
var chart = anychart.heatMap(data);
9
10
var colorScale = anychart.scales.ordinalColor();
11
// set color for all points
12
colorScale.ranges([
13
{ less: 0.35, color: '#e3f2fd' },
14
{ from: 0.35, to: 0.45, color: '#D3EDFC' },
15
{ from: 0.45, to: 0.5, color: '#BEE7FC' },
16
{ from: 0.5, to: 0.55, color: '#aee2fb' },
17
{ from: 0.55, to: 0.6, color: '#B3B0D3' },
18
{ from: 0.6, to: 0.65, color: '#B691BB' },
19
{ from: 0.65, to: 0.7, color: '#B973A3' },
20
{ from: 0.7, to: 0.75, color: '#BC558B' },
21
{ from: 0.75, to: 0.8, color: '#BF3673' },
22
{ greater: 0.8, color: '#c2185b' }
23
]);
24
chart.colorScale(colorScale);
25
26
// Sets selection mode for single selection
27
chart.interactivity().selectionMode('none');
28
29
chart.padding([10, 20, 10, 20]);
30
31
// Sets title
32
chart
33
.title()
34
.useHtml(true)
35
.enabled(true)
36
.padding([0, 0, 10, 5])
37
.align('left')
38
.text(
39
'Poker Spread Sheet <span style=\'font-size: 13px; color:#B9B9B9\'>(Texas Hold\'em)</span>'
40
);
41
42
// Sets chart labels
43
chart
44
.labels()
45
.enabled(true)
46
.maxFontSize(14)
47
.format(function () {
48
return this.x + this.y + this.getData('symbol');
49
});
50
51
// Turns off axes
52
chart
53
.yAxis(null)
54
.xAxis(null)
55
// Sets chart and hover chart settings
56
.stroke('#fff');
57
chart
58
.hovered()
59
.stroke('6 #fff')
60
.fill('#545f69')
61
.labels({ fontColor: '#fff' });
62
63
// Sets legend
64
chart
65
.legend()
66
.enabled(true)
67
.align('top')
68
.position('right')
69
.itemsLayout('vertical')
70
.padding([2, 10, 0, 20]);
71
72
// Sets tooltip
73
chart
74
.tooltip()
75
.titleFormat(function () {
76
var s = '';
77
if (this.getData('symbol') === 's') s = 'suited';
78
else if (this.getData('symbol') === 'u') s = 'unsuited';
79
return this.x + this.y + ' ' + s;
80
})
81
.format(function () {
82
return 'Win statistic: ' + this.heat;
83
});
84
85
chart.container('container');
86
chart.draw();
87
}
88
);
89
});