gopster

package module
v0.0.0-...-a80effe Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 11 Imported by: 0

README

Gopster

Go Reference

A Go port of camdendotlol/topster. Unlikely to ever be stable or tagged; expect breaking changes.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorChart = errors.New("gopster: error creating chart")

ErrorChart is returned when a chart is misconfigured.

View Source
var ErrorItem = errors.New("gopster: chart item is misconfigured")

ErrorItem is returned when a chart item is misconfigured.

Functions

This section is empty.

Types

type Chart

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

Chart is a Topster chart.

func NewChart

func NewChart(opts ...Option) (*Chart, error)

NewChart creates a new chart with the given settings.

func (*Chart) AddItem

func (c *Chart) AddItem(title string, creator string, img image.Image) error

AddItem adds an item to a chart.

func (*Chart) Generate

func (c *Chart) Generate() image.Image

Generate renders a chart into an image.

func (*Chart) MustAddItem

func (c *Chart) MustAddItem(title, creator string, img image.Image)

MustAddItem is the same as AddItem, except it will panic on error.

type Option

type Option func(*Chart)

Option configures a chart.

func BackgroundColor

func BackgroundColor(bc string) Option

BackgroundColor sets a chart's background color. Must be a valid hex color string. Defaults to black.

func Gap

func Gap(g float64) Option

Gap sets a chart's gap. Defaults to 20.

func Height

func Height(h int) Option

Height sets a chart's height. Defaults to 3.

func ShowNumbers

func ShowNumbers() Option

ShowNumbers toggles number rendering on a chart. Defaults to false. ShowTitles must also be true for this to work.

func ShowTitles

func ShowTitles() Option

ShowTitles toggles title rendering on a chart. Defaults to false.

func TextColor

func TextColor(tc string) Option

TextColor sets a chart's text color. Must be a valid hex color string. Defaults to white.

func Title

func Title(t string) Option

Title sets a chart's title. Defaults to an empty string.

func Width

func Width(w int) Option

Width sets a chart's width. Defaults to 3.

Jump to

Keyboard shortcuts

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