grapher

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package grapher provides a tool for easily creating graphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphType

type GraphType int

GraphType is used to define the type of graph you need.

const (
	// Normal GraphType provides a grapher where you can set points a certain dates.
	Normal GraphType = iota
	// Cumulative GraphType will accumulate all previous values on your graph.
	Cumulative GraphType = iota
	// CumulativeSameDate GraphType will accumulate values
	// with the same date on your graph.
	CumulativeSameDate GraphType = iota
)

type Grapher

type Grapher[T Numeric] struct {
	// contains filtered or unexported fields
}

Grapher is used to easily create graphs.

func New

func New[T Numeric](
	graphType GraphType,
	interpolationType InterpolationType,
	dateFormat string,
	dateGranularity time.Duration,
) *Grapher[T]

New returns a new Grapher.

func (*Grapher[T]) AddPoint

func (grapher *Grapher[T]) AddPoint(date time.Time, value T, label string)

AddPoint adds a new point to the graph.

func (Grapher[T]) ToSlices

func (grapher Grapher[T]) ToSlices() ([]string, map[string][]T)

ToSlices returns the graph as a string slice of dates and a typed slice of values.

func (Grapher[T]) ToStringSlices

func (grapher Grapher[T]) ToStringSlices() ([]string, map[string][]string)

ToStringSlices returns the graph as a string slice of dates and values.

type InterpolationType added in v0.3.4

type InterpolationType int

InterpolationType is used to define the type of interpolation you need.

const (
	// None InterpolationType provides a grapher that won't interpolate.
	None InterpolationType = iota
	// Zero InterpolationType provides a grapher that will interpolate using value zero.
	Zero InterpolationType = iota
	// PreviousValue InterpolationType provides a grapher
	// that will interpolate using the previous value.
	PreviousValue InterpolationType = iota
)

type Numeric

type Numeric interface {
	int | int64 | float64
}

Numeric is a union of all numeric types.

Jump to

Keyboard shortcuts

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