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-with-scroll/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/heat-map-charts/heat-map-with-scroll/data.json',
6
function (data) {
7
// Creates Heat Map
8
var chart = anychart.heatMap(data);
9
10
// Sets colorScale
11
var colorScale = anychart.scales.ordinalColor();
12
// Sets colors for all points
13
colorScale.ranges([
14
{ less: 25000, color: '#fff9c4' },
15
{ from: 25000, to: 45000, color: '#ffe082' },
16
{ from: 45000, to: 65000, color: '#ffca28' },
17
{ from: 65000, to: 80000, color: '#ffa000' },
18
{ greater: 80000, color: '#ff6f00' }
19
]);
20
chart.colorScale(colorScale);
21
22
// Sets chart title
23
chart
24
.title()
25
.enabled(true)
26
.text('Sales Team Achievements during 2014')
27
.padding([0, 0, 20, 0]);
28
29
// Sets chart labels
30
chart.labels().enabled(true).format('${%Heat}');
31
32
// Sets Scrolls for Axes
33
chart.xScroller(true);
34
chart.yScroller(true);
35
36
// Sets starting zoom for Axes
37
chart.xZoom().setToPointsCount(8);
38
chart.yZoom().setToPointsCount(6);
39
40
// Sets chart and hover chart settings
41
chart.stroke('#fff');
42
chart
43
.hovered()
44
.stroke('6 #fff')
45
.fill('#545f69')
46
.labels({ fontColor: '#fff' });
47
48
// Sets legend
49
chart
50
.legend()
51
.enabled(true)
52
.align('center')
53
.position('center-bottom')
54
.itemsLayout('horizontal')
55
.padding([20, 0, 0, 0]);
56
57
// set container id for the chart
58
chart.container('container');
59
// initiate chart drawing
60
chart.draw();
61
}
62
);
63
});