axis

package
v0.0.0-...-fd21f57 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

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

Axis defines an axis (doh)

func New

func New(p Position, f Formatter) *Axis

New creates a new Axis on the specified position using the formatter.

func NewSI

func NewSI(p Position, base int) *Axis

NewSI creates a new Axis on the specified position using the default SI formatter.

func NewTime

func NewTime(p Position, timefmt string) *Axis

NewTime creates a new Axis on the specified position using the default Time formatter. A timefmt is specified using the default Go Time format, e.g. 2006-01-02 15:04

func (*Axis) Center

func (a *Axis) Center() *Axis

Center aligns the label in tne center of the grid instead of the start/end of grid.

func (*Axis) Draw

func (a *Axis) Draw(img image.Image, w, h, mx, my int, min, max float64)

Draw renders the grid and labels. mx/my is the top-left start position, the margin (or offset). FIXME there are text-margin constants in this function which are probably dependent on the font and size used. It also depends a bit too much on the actual font/line/color drawing stuff.

func (*Axis) Duration

func (a *Axis) Duration(d time.Duration) *Axis

Duration sets the time period for the gridlines/labels or ticks for the axis. This configures a grid aligned to the nearest time unit. Use either one of Ticks() or Duration()

func (*Axis) Grid

func (a *Axis) Grid(n int) *Axis

Grid displays a grid for this axis. By default it doesn't show a grid. n is the amount of gridlines to draw between axis ticks. If your axis spans 4 hours and n = 2 then a gridline will be drawn every 2 hours.

func (*Axis) Scales

func (a *Axis) Scales(h int, min, max float64) []string

Scales creates and formats the Y-axis scale.

func (*Axis) Ticks

func (a *Axis) Ticks(n int) *Axis

Ticks sets the number of gridlines/labels or ticks for this axis. This configures an equally centered grid pattern for an axis. Use either one of Ticks() or Duration()

type Formatter

type Formatter func(value float64) string

Formatter is the callback interface function used to format a label.

type Liner

type Liner func(x1, y1, x2, y2 int)

Liner is the callback interface function to draw a line. Any padding/margin offsets should be applied by the caller.

type Position

type Position int

Position defines the position for the axis. Bottom, Top, Left or Right

const (
	// Bottom defines an axis aligned to the bottom of the image.
	Bottom Position = iota

	// Left defines an axis aligned to the let of the image.
	// Only Bottom and Left are defined at the moment.
	Left
)

Jump to

Keyboard shortcuts

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