https://github.com/blurfx/calendar-heatmap
Calendar heatmap svg generator written in go
https://github.com/blurfx/calendar-heatmap
calendar calendar-heatmap codegen codegenerator contribution-graph contributions-calendar go golang heatmap heatmap-visualization svg visualization
Last synced: 5 months ago
JSON representation
Calendar heatmap svg generator written in go
- Host: GitHub
- URL: https://github.com/blurfx/calendar-heatmap
- Owner: blurfx
- License: mit
- Created: 2021-04-03T16:19:06.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-11T08:01:41.000Z (almost 4 years ago)
- Last Synced: 2024-06-21T06:42:04.359Z (10 months ago)
- Topics: calendar, calendar-heatmap, codegen, codegenerator, contribution-graph, contributions-calendar, go, golang, heatmap, heatmap-visualization, svg, visualization
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Calendar-Heatmap
Generate svg image of calendar heatmap like GitHub contribution graph.
## Guide
### Installation
```
go get github.com/blurfx/calendar-heatmap
```### Example
```go
package mainimport (
"fmt"
"github.com/blurfx/calendar-heatmap"
)func main() {
data := make(map[heatmap.Date]int)data[heatmap.Date{Year: 2021, Month: 1, Day: 1}] = 1
data[heatmap.Date{Year: 2021, Month: 2, Day: 21}] = 3
data[heatmap.Date{Year: 2021, Month: 3, Day: 17}] = 4h := heatmap.New(nil)
buffer := h.Generate(
heatmap.Date{Year: 2021, Month: 1, Day: 1},
heatmap.Date{Year: 2021, Month: 3, Day: 31},
data,
)fmt.Println(buffer.String())
// ...
}
```### Heatmap Customization
You can customize heat maps using the CalendarHeatmapConfig structure.
#### Default Configs
```go
&CalendarHeatmapConfig{
Colors: []string{"#EBEDF0", "#9BE9A8", "#40C463", "#30A14E", "#216E39"},
BlockSize: 11,
BlockMargin: 2,
BlockRoundness: 2,
MonthLabels: []string{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
MonthLabelHeight: 15,
WeekdayLabels: []string{"", "Mon", "", "Wed", "", "Fri", ""},
}
```#### Using your own configuration
```go
myConfig := &heatmap.CalendarHeatmapConfig{
// ...
}h := heatmap.New(myConfig)
```## Example Output
