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
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
// create and configure a color scale.
26
var customColorScale = anychart.scales.ordinalColor();
27
customColorScale.ranges([
28
{less: 3},
29
{from: 4, to: 6},
30
{greater: 7},
31
]);
32
customColorScale.colors(["lightgray", "#ffcc00", "#00ccff"]);
33
34
// set the color scale as the color scale of the chart
35
chart.colorScale(customColorScale);
36
37
// configure the color range
38
chart.colorRange().length("90%");
39
40
// configure years
41
chart.years().title().fontSize(30);
42
43
// set the chart title
44
chart.title().useHtml(true);
45
chart.title("Calendar Chart: Color Scale (Ordinal)<br><br>" +
46
"<span style='font-size:12; font-style:italic'>" +
47
"GitHub Contributions</span>");
48
49
// set the container id
50
chart.container("container");
51
52
// initiate drawing the chart
53
chart.draw();
54
});