HTMLcopy
1
<div id="container"></div>
CSScopy
5
1
html, body, #container {
2
width: 100%;
3
margin: 0;
4
padding: 0;
5
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function() {
2
anychart.data.loadJsonFile(
3
'https://cdn.anychart.com/samples/calendar-chart/github-contributions/data.json',
4
function(data) {
5
var dataset = anychart.data.set(data);
6
var mapping = dataset.mapAs({
7
x: 'date',
8
value: 'level'
9
});
10
var chart = anychart.calendar(mapping);
11
12
chart.background('#22282D');
13
14
chart.months()
15
.stroke(false)
16
.noDataStroke(false);
17
18
chart.days()
19
.spacing(5)
20
.stroke(false)
21
.noDataStroke(false)
22
.noDataFill('#2d333b')
23
.noDataHatchFill(false);
24
25
chart.colorRange(false);
26
27
var customColorScale = anychart.scales.ordinalColor();
28
customColorScale.ranges([
29
{equal: 1, color: '#0D4428'},
30
{equal: 2, color: '#006D31'},
31
{equal: 3, color: '#37AB4B'},
32
{equal: 4, color: '#39D353'}
33
]);
34
35
// Set color scale.
36
chart.colorScale(customColorScale);
37
38
chart.tooltip()
39
.format('{%count} contributions');
40
41
chart.listen('chartDraw', function() {
42
document.getElementById('container').style.height = chart.getActualHeight() + 'px';
43
});
44
45
chart.container('container');
46
chart.draw();
47
}
48
);
49
});