charts

package
v2.0.1-0...-83993d3 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFontFace

func LoadFontFace(fontBytes []byte) (font.Face, error)

LoadFontFace loads font face from bytes

func LoadFontFaceFromFile

func LoadFontFaceFromFile(fontPath string) (font.Face, error)

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

type BasicColorScale []color.RGBA

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

func (BasicColorScale) GetColor

func (c BasicColorScale) GetColor(val float64) color.RGBA

GetColor returns color based on float value from 0 to 1

type ColorScale

type ColorScale interface {
	GetColor(val float64) color.RGBA
}

ColorScale is interface for extracting color based on value from 0 to 1

type Day

type Day struct {
	Count int
	Date  string
	Color string
	Show  bool
}

Day is SVG template day parameters

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

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(counts map[string]int, offset image.Point, boxSize int, margin int) *DayIterator

NewDayIterator initializes iterator for a year

func (*DayIterator) Count

func (d *DayIterator) Count() int

Count returns count value

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

type MonthLabel struct {
	Label   string
	XOffset int
}

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

type WeekdayLabel struct {
	Label string
	Show  bool
}

WeekdayLabel is SVG template weekday label parameters

Jump to

Keyboard shortcuts

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