charts

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2020 License: MIT Imports: 8 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHeatmap

func NewHeatmap(conf HeatmapConfig) image.Image

NewHeatmap creates image with heatmap and additional elements

Types

type DayBoxVisitor

type DayBoxVisitor struct {
	Img        *image.RGBA
	ColorScale colorscales.ColorScale
	BoxSize    int
}

DayBoxVisitor draws signle heatbox

func (*DayBoxVisitor) Visit

func (d *DayBoxVisitor) Visit(iter *DayIterator)

Visit called on every iteration

type DayIterator

type DayIterator struct {
	Year int
	Row  int
	Col  int
	// contains filtered or unexported fields
}

DayIterator has data for updating image based on a day

func NewDayIterator

func NewDayIterator(year int, offset image.Point, countByDay map[int]int, boxSize int, margin int) *DayIterator

NewDayIterator initilizes 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 {
	Year               int
	CountByDay         map[int]int
	ColorScale         colorscales.ColorScale
	DrawMonthSeparator bool
	DrawLabels         bool
	BoxSize            int
	Margin             int
	TextWidthLeft      int
	TextHightTop       int
	TextColor          color.RGBA
	BorderColor        color.RGBA
}

HeatmapConfig contains config of calendar heatmap image

type MonthLabelsVisitor

type MonthLabelsVisitor struct {
	Img     *image.RGBA
	YOffset int
	Color   color.RGBA
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL