1
0
mirror of https://github.com/nikolaydubina/calendarheatmap.git synced 2025-01-19 12:54:58 +02:00
calendarheatmap/README.md

75 lines
2.2 KiB
Markdown
Raw Normal View History

2020-07-02 03:23:17 +08:00
[![Go Report Card](https://goreportcard.com/badge/github.com/nikolaydubina/calendarheatmap)](https://goreportcard.com/report/github.com/nikolaydubina/calendarheatmap)
2020-07-13 13:46:59 +08:00
[![GoDev](https://img.shields.io/static/v1?label=godev&message=reference&color=00add8)](https://pkg.go.dev/github.com/nikolaydubina/calendarheatmap/charts)
2020-07-03 15:27:49 +08:00
[![codecov](https://codecov.io/gh/nikolaydubina/calendarheatmap/branch/master/graph/badge.svg)](https://codecov.io/gh/nikolaydubina/calendarheatmap)
2020-07-04 12:11:30 +08:00
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)
2020-07-03 10:56:33 +08:00
2020-07-02 03:04:05 +08:00
Self-contained, plain Go implementation of calendar heatmap inspired by Github contribution activity.
2020-07-02 03:02:51 +08:00
```
$ go build
$ echo '{
"2020-05-16": 8,
"2020-05-17": 13,
"2020-05-18": 5,
"2020-05-19": 8,
"2020-05-20": 5
}' | ./calendarheatmap > chart.png
```
2020-07-03 15:16:42 +08:00
Basic
2020-07-03 15:16:42 +08:00
![basic](charts/testdata/basic.png)
2020-07-02 02:48:34 +08:00
Colorscales
2020-07-03 15:16:42 +08:00
![col1](charts/testdata/colorscale_1.png)
![col2](charts/testdata/colorscale_2.png)
2020-07-02 02:48:34 +08:00
2020-07-02 02:50:20 +08:00
Without month separator
2020-07-03 15:16:42 +08:00
![nosep](charts/testdata/noseparator.png)
2020-07-02 02:48:34 +08:00
2020-07-02 20:07:08 +08:00
Without labels
2020-07-03 15:16:42 +08:00
![nolab](charts/testdata/nolabels.png)
2020-07-02 20:07:08 +08:00
Without labels, without separator
2020-07-03 15:16:42 +08:00
![nosep_nolab](charts/testdata/noseparator_nolabels.png)
2020-07-02 20:07:08 +08:00
2020-07-04 12:23:17 +08:00
Example module, next save output in formats supported by `image` module (PNG, JPEG, GIF).
2020-07-03 09:54:43 +08:00
```go
countByDayOfYear := map[int]int{
1: 10,
22: 15,
150: 22,
366: 55,
2020-07-04 12:18:57 +08:00
...
2020-07-03 09:54:43 +08:00
}
img := charts.NewHeatmap(charts.HeatmapConfig{
Year: 2020,
CountByDay: countByDay,
ColorScale: colorscales.PuBu9,
DrawMonthSeparator: true,
DrawLabels: true,
...
})
```
Example script
2020-07-03 15:34:57 +08:00
```
$ cat testdata/basic.json | ./calendarheatmap -output jpeg > chart.jpeg
$ cat testdata/custom.txt | ./calendarheatmap -input row-day-seconds-count > custom.png
2020-07-11 19:16:11 +08:00
$ ./calendarheatmap -h
2020-07-04 12:23:17 +08:00
Usage of ./calendarheatmap:
-colorscale string
2020-07-11 17:29:14 +08:00
refer to colorscales for examples (default "PuBu9")
2020-07-04 12:23:17 +08:00
-input string
format of input file, refer to parsers module (default "json-basic")
2020-07-04 12:23:17 +08:00
-labels
2020-07-11 17:29:14 +08:00
labels for weekday and months (default true)
2020-07-04 12:23:17 +08:00
-monthsep
2020-07-11 17:29:14 +08:00
render month separator (default true)
2020-07-04 12:23:17 +08:00
-output string
2020-07-11 18:49:27 +08:00
output format (png, jpeg, gif) (default "png")
2020-07-13 13:46:59 +08:00
```