Documentation
¶
Index ¶
- func LoadFontFace(fontBytes []byte) (font.Face, error)
- func LoadFontFaceFromFile(fontPath string) (font.Face, error)
- func WriteHeatmap(conf HeatmapConfig, w io.Writer) error
- type BasicColorScale
- type ColorScale
- type Day
- type DayBoxVisitor
- type DayIterator
- type DayVisitor
- type HeatmapConfig
- type LabelsProvider
- type MonthLabel
- type MonthLabelsVisitor
- type MonthSeparatorVisitor
- type Params
- type WeekdayLabel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFontFace ¶
LoadFontFace loads font face from bytes
func LoadFontFaceFromFile ¶
LoadFontFaceFromFile loads font face from file
func WriteHeatmap ¶
func WriteHeatmap(conf HeatmapConfig, w io.Writer) error
WriteHeatmap writes image with heatmap and additional elements
Types ¶
type BasicColorScale ¶
BasicColorScale is color scale with variable number of colors
func NewBasicColorscaleFromCSV ¶
func NewBasicColorscaleFromCSV(reader io.Reader) (BasicColorScale, error)
NewBasicColorscaleFromCSV creates colorscale from reader
func NewBasicColorscaleFromCSVFile ¶
func NewBasicColorscaleFromCSVFile(path string) (BasicColorScale, error)
NewBasicColorscaleFromCSVFile loads basic colorscale from CSV file
type ColorScale ¶
ColorScale is interface for extracting color based on value from 0 to 1
type DayBoxVisitor ¶
type DayBoxVisitor struct { Img *image.RGBA ColorScale ColorScale BoxSize int }
DayBoxVisitor draws signle heatbox
func (*DayBoxVisitor) Visit ¶
func (d *DayBoxVisitor) Visit(iter *DayIterator)
Visit called on every iteration
type DayIterator ¶
DayIterator has data for updating image based on a day
func NewDayIterator ¶
func NewDayIterator(counts map[string]int, offset image.Point, boxSize int, margin int) *DayIterator
NewDayIterator initializes iterator for a year
func (*DayIterator) Done ¶
func (d *DayIterator) Done() bool
Done returns true if no entries left, else false
func (*DayIterator) Next ¶
func (d *DayIterator) Next()
Next will update current iterator to next value
func (*DayIterator) Point ¶
func (d *DayIterator) Point() image.Point
Point returns position of top left corner of box for drawing
func (*DayIterator) Time ¶
func (d *DayIterator) Time() time.Time
Time returns time representation of iterator
func (*DayIterator) Value ¶
func (d *DayIterator) Value() float64
Value returns relative value in range 0 ~ 1
type DayVisitor ¶
type DayVisitor interface {
Visit(iter *DayIterator)
}
DayVisitor is interface to update image based on current box
type HeatmapConfig ¶
type HeatmapConfig struct { Counts map[string]int ColorScale ColorScale DrawMonthSeparator bool DrawLabels bool BoxSize int Margin int TextWidthLeft int TextHeightTop int TextColor color.RGBA BorderColor color.RGBA Locale string Format string FontFace font.Face ShowWeekdays map[time.Weekday]bool }
HeatmapConfig contains config of calendar heatmap image
type LabelsProvider ¶
type LabelsProvider struct {
// contains filtered or unexported fields
}
LabelsProvider provides labels for locale
func NewLabelsProvider ¶
func NewLabelsProvider(locale string) LabelsProvider
NewLabelsProvider initializes labels provider for locale
func (LabelsProvider) GetMonth ¶
func (p LabelsProvider) GetMonth(month time.Month) string
GetMonth returns month label
func (LabelsProvider) GetWeekday ¶
func (p LabelsProvider) GetWeekday(weekday time.Weekday) string
GetWeekday returns weekday label
type MonthLabel ¶
MonthLabel is SVG template month label parameters
type MonthLabelsVisitor ¶
type MonthLabelsVisitor struct { Img *image.RGBA YOffset int Color color.RGBA LabelsProvider LabelsProvider FontFace font.Face }
MonthLabelsVisitor draws month label on top of first row 0 of month
func (*MonthLabelsVisitor) Visit ¶
func (d *MonthLabelsVisitor) Visit(iter *DayIterator)
Visit on every iteration
type MonthSeparatorVisitor ¶
type MonthSeparatorVisitor struct { Img *image.RGBA MinY int MaxY int Margin int BoxSize int Width int Color color.RGBA }
MonthSeparatorVisitor draws month separator
func (*MonthSeparatorVisitor) Visit ¶
func (d *MonthSeparatorVisitor) Visit(iter *DayIterator)
Visit called on every iteration
type Params ¶
type Params struct { Days [53][7]Day LabelsMonths [12]MonthLabel LabelsWeekdays [7]WeekdayLabel LabelsColor string }
Params is total SVG template parameters
type WeekdayLabel ¶
WeekdayLabel is SVG template weekday label parameters