sparkline

package
v0.0.0-...-139f653 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sparkline draws small charts of timeseries data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gradient

func Gradient(a, b color.Color, percentage float32) color.Color

Gradient picks a color that's somewhere in between a and b, depending on percentage. 0.0 results in a, 1.0 results in b.

func PickColor

func PickColor(thresholds []Threshold, value uint64) color.Color

PickColor picks a color in based on the given thresholds.

Thresholds are expected to be in decreasing order.

If value is greater than or equal to the greatest Max, the color from that threshold is returned.

If value is less than the Max of the last threshold, the color from that threshold is returned.

Otherwise, the color will be proportionally in between the color of the matching threshold and the next one, based on where value is between the two Max values.

Types

type Sparkline

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

func New

func New(items int, fg color.Color, thresholds []Threshold) *Sparkline

func (*Sparkline) Add

func (s *Sparkline) Add(n float32)

func (*Sparkline) Draw

func (s *Sparkline) Draw(dst draw.Image)

type Threshold

type Threshold struct {
	Max   uint64
	Color color.Color
}

Threshold gives a color to use for values near Max.

Jump to

Keyboard shortcuts

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