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-03 13:36:41 +08:00
|
|
|
[![GoDev](https://img.shields.io/static/v1?label=godev&message=reference&color=00add8)](https://pkg.go.dev/github.com/nikolaydubina/calendarheatmap@v1.0.0/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
|
|
|
|
2020-07-03 15:16:42 +08:00
|
|
|
Basic
|
|
|
|
![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,
|
|
|
|
...
|
|
|
|
})
|
2020-07-04 12:18:57 +08:00
|
|
|
|
2020-07-03 09:54:43 +08:00
|
|
|
```
|
|
|
|
|
2020-07-04 12:23:17 +08:00
|
|
|
Example script, will output as PNG.
|
2020-07-03 15:34:57 +08:00
|
|
|
```
|
2020-07-04 12:23:17 +08:00
|
|
|
$ go build; ./calendarheatmap -h
|
|
|
|
|
|
|
|
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
|
2020-07-11 17:29:14 +08:00
|
|
|
file should contain lines in format: 2020-05-16 20:43 PPPP (default "input.txt")
|
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 17:29:14 +08:00
|
|
|
output filename, will export as PNG (default "chart.png")
|
|
|
|
-output-format string
|
|
|
|
output format (png, jpeg, gif) (default "png"))
|
2020-07-03 15:34:57 +08:00
|
|
|
```
|
2020-07-04 12:17:46 +08:00
|
|
|
|
|
|
|
TODO:
|
|
|
|
- [ ] SVG support
|
|
|
|
- [ ] select start and end date
|
|
|
|
- [ ] CSV, JSON in script input
|