HTMLcopy
1
<label><input onclick="yearsInverted(false)" type="radio" name="type" checked>Straight Order</label>
2
<label><input onclick="yearsInverted(true)" type="radio" name="type">Inverted Order</label>
3
<div id="container"></div>
CSScopy
16
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
label {
8
display: inline-block;
9
margin: 10px 0 0 10px;
10
}
11
#container {
12
position: absolute;
13
width: 100%;
14
top: 35px;
15
bottom: 0;
16
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
{x: "2020-01-12", value: "6"},
6
{x: "2020-01-15", value: "2"},
7
{x: "2020-01-18", value: "2"},
8
{x: "2020-01-19", value: "5"},
9
{x: "2020-02-03", value: "1"},
10
{x: "2020-02-19", value: "9"},
11
{x: "2020-03-19", value: "2"},
12
{x: "2020-04-13", value: "3"},
13
{x: "2020-04-15", value: "3"},
14
{x: "2020-04-20", value: "4"},
15
{x: "2020-04-21", value: "1"},
16
{x: "2020-05-10", value: "3"},
17
{x: "2020-05-11", value: "1"},
18
{x: "2020-05-14", value: "1"},
19
{x: "2021-01-12", value: "2"}
20
];
21
22
// create a chart and set the data
23
var chart = anychart.calendar(data);
24
25
// configure years
26
years = chart.years();
27
years.background("#e7f3fd");
28
years.title().fontColor("#dd2c00");
29
years.title().fontSize(30);
30
years.title().fontWeight(600);
31
years.underSpace(4);
32
33
// configure years
34
chart.years().title().fontSize(30);
35
36
// set the chart title
37
chart.title().useHtml(true);
38
chart.listen("chartDraw", function () {
39
chart.title("Calendar Chart: Years (Inverted = " + years.inverted() +
40
")<br><br><span style='font-size:12; font-style:italic'>" +
41
"GitHub Contributions</span>");
42
});
43
44
// set the container id
45
chart.container("container");
46
47
// initiate drawing the chart
48
chart.draw();
49
});
50
51
// set the order of years
52
function yearsInverted(inverted) {
53
years.inverted(inverted);
54
}