charts

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 21 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFontFace added in v1.5.0

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

LoadFontFace loads font face from bytes

func LoadFontFaceFromFile added in v1.4.1

func LoadFontFaceFromFile(fontPath string, options opentype.FaceOptions) (font.Face, error)

LoadFontFaceFromFile loads font face from file

func WriteHeatmap added in v1.4.1

func WriteHeatmap(conf HeatmapConfig, w io.Writer) error

WriteHeatmap writes image with heatmap and additional elements

Types

type BasicColorScale added in v1.4.1

type BasicColorScale []color.RGBA

BasicColorScale is color scale with variable number of colors

func NewBasicColorscaleFromCSV added in v1.5.0

func NewBasicColorscaleFromCSV(reader io.Reader) (BasicColorScale, error)

NewBasicColorscaleFromCSV creates colorscale from reader

func NewBasicColorscaleFromCSVFile added in v1.4.1

func NewBasicColorscaleFromCSVFile(path string) (BasicColorScale, error)

NewBasicColorscaleFromCSVFile loads basic colorscale from CSV file

func (BasicColorScale) GetColor added in v1.4.1

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

GetColor returns color based on float value from 0 to 1

type ColorScale added in v1.4.1

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

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

type Day added in v1.4.0

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 added in v1.4.0

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
	MonthSeparatorWidth int
	MonthLabelYOffset   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 added in v1.3.0

type LabelsProvider struct {
	// contains filtered or unexported fields
}

LabelsProvider provides labels for locale

func NewLabelsProvider added in v1.3.0

func NewLabelsProvider(locale string) LabelsProvider

NewLabelsProvider initializes labels provider for locale

func (LabelsProvider) GetMonth added in v1.3.0

func (p LabelsProvider) GetMonth(month time.Month) string

GetMonth returns month label

func (LabelsProvider) GetWeekday added in v1.3.0

func (p LabelsProvider) GetWeekday(weekday time.Weekday) string

GetWeekday returns weekday label

type MonthLabel added in v1.4.1

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 added in v1.4.0

type Params struct {
	BoxAreaHeight   int
	BoxAreaWidth    int
	BoxSize         int
	Margin          int
	Days            [53][7]Day
	LabelsMonths    []MonthLabel
	LabelsWeekdays  []WeekdayLabel
	LabelsColor     string
	MonthSeparators []string
}

Params is total SVG template parameters

type WeekdayLabel added in v1.4.0

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