plot

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const NoSeries = SeriesId(0)

Variables

This section is empty.

Functions

func BrailleCellMapper

func BrailleCellMapper(row Row, col Column, size ScreenSize) int

func DrawAxes

func DrawAxes(ticks *ScreenTicks, output func(row Row, col Column, cell rune, kind AxisCellKind))

func DrawBraille

func DrawBraille(graph *RenderedGraph, output func(row Row, col Column, cell rune, id SeriesId))

Types

type AxisCellKind

type AxisCellKind int
const (
	DomainTickKind AxisCellKind = iota
	RangeTickKind
	YAxisKind
	XAxisKind
	AxisCornerKind
	LabelKind
)

type Cell

type Cell struct {
	// common path doesn't need to allocate a slice
	IsPoint bool
	Series  SeriesId

	MoreSeries []SeriesId
}

type Column

type Column int

type DomainLabeler

type DomainLabeler func(int64) string

type DomainProjector

type DomainProjector func(int64) Column

DomainProjector maps a platonic domain into a screen domain. Use it to convert data points into pixels

type DomainTick

type DomainTick struct {
	Col   Column
	Value int64
	Label string
}

type LabelInfo

type LabelInfo struct {
	DomainLabels, RangeLabels []string

	MarginRows Row
	MarginCols Column
}

type Labeling

type Labeling struct {
	DomainLabeler
	RangeLabeler
	LineSize int
}

type PixelPoint

type PixelPoint struct {
	Row Row
	Col Column

	OriginalPoints []Point
}

type PlatonicAxes

type PlatonicAxes struct {
	DomainMin, DomainMax int64
	RangeMin, RangeMax   float64
}

func AutoAxes

func AutoAxes() PlatonicAxes

func (PlatonicAxes) WithPreviousRange

func (a PlatonicAxes) WithPreviousRange(oldAxes PlatonicAxes) PlatonicAxes

type PlatonicGraph

type PlatonicGraph struct {
	PlatonicAxes

	Series SeriesSet
}

func DataToPlatonicGraph

func DataToPlatonicGraph(seriesSet SeriesSet, baseAxes PlatonicAxes) *PlatonicGraph

func (PlatonicGraph) ScalePlatonicToScreen

func (g PlatonicGraph) ScalePlatonicToScreen(scale RangeScale, size ScreenSize) (func(int64) Column, func(float64) Row)

func (*PlatonicGraph) ToScreen

func (g *PlatonicGraph) ToScreen(scale RangeScale, size ScreenSize) *ScreenGraph

type Point

type Point interface {
	Y() float64
	X() int64
}

type RangeLabeler

type RangeLabeler func(float64) string

type RangeProjector

type RangeProjector func(float64) Row

RangeProjector maps a platonic range into a screen range. Use it to convert data points into pixels

type RangeScale

type RangeScale func(float64) float64

RangeScale maps a platonic range to another platonic range. Use it to do stuff like apply log scales

type RangeTick

type RangeTick struct {
	Row   Row
	Value float64
	Label string
}

type RenderedGraph

type RenderedGraph struct {
	Cells []Cell
	ScreenSize
	SubCellMapper SubCellMapper
}

type Row

type Row int

type ScreenGraph

type ScreenGraph struct {
	ScreenSize

	Series []ScreenSeries
}

func (*ScreenGraph) Render

func (s *ScreenGraph) Render(subCellMapper SubCellMapper) *RenderedGraph

type ScreenSeries

type ScreenSeries struct {
	Points []PixelPoint
	Id     SeriesId
}

type ScreenSize

type ScreenSize struct {
	Rows Row
	Cols Column
}

func BrailleCellScreenSize

func BrailleCellScreenSize(termSize ScreenSize) ScreenSize

type ScreenTicks

type ScreenTicks struct {
	DomainTicks []DomainTick
	RangeTicks  []RangeTick

	InnerGraphSize ScreenSize
	MarginRows     Row
	MarginCols     Column
	LineSize       int
}

func EvenlySpacedTicks

func EvenlySpacedTicks(graph *PlatonicGraph, outerSize ScreenSize, scale TickScaling, labels Labeling) *ScreenTicks

type Series

type Series interface {
	Title() string

	// Id should be unique in a given SeriesSet, and should be consistent
	// across refreshes to ensure things like coloring and ordering stay
	// consistent.  It must not be NoSeries.
	Id() SeriesId

	// Points *must* have a domain that is monotinically increasing
	Points() []Point
}

type SeriesId

type SeriesId uint16

SeriesId identifies some series. The zero value is reserved for unset.

type SeriesSet

type SeriesSet []Series

type SubCellMapper

type SubCellMapper func(row Row, col Column, size ScreenSize) int

type TickScaling

type TickScaling struct {
	RangeScale RangeScale

	RangeDensity  int
	DomainDensity int
}

Jump to

Keyboard shortcuts

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