chart

package module
v0.0.0-...-6170a5c Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 17 Imported by: 0

README ΒΆ

chart

Action Report Card Lines of code godoc License

✨ xuender/chart is a ...

πŸš€ Install

go install github.com/xuender/chart@latest

πŸ’‘ Usage

TODO

πŸ‘€ Contributors

Contributors

πŸ“ License

Β© ender, 2024~time.Now

MIT LICENSE

Documentation ΒΆ

Overview ΒΆ

nolint: mnd

Index ΒΆ

Examples ΒΆ

Constants ΒΆ

View Source
const (
	DefaultBorderWidth = 2
	DefaultLineWidth   = 2
	DefaultTitleSize   = 80
	DefaultWidth       = 800
	DefaultHeight      = 600
)

Variables ΒΆ

View Source
var (
	DebugTitle = canvas.RGBA(255, 0, 0, 0.2)
	DebugChart = canvas.RGBA(0, 0, 255, 0.2)
)

nolint: gochecknoglobals, mnd

View Source
var DefaultFonts = NewDefaultFonts()

nolint: gochecknoglobals

Functions ΒΆ

func Lines ΒΆ

func Lines[K cmp.Ordered, V Number](lines []iter.Seq2[K, V]) ([]K, [][]canvas.Point)

func LinesRect ΒΆ

func LinesRect(data [][]canvas.Point) canvas.Rect

func ShuffleSlice ΒΆ

func ShuffleSlice[T any](slice []T, step int) []T
Example ΒΆ
package main

import (
	"fmt"

	"github.com/xuender/chart"
)

func main() {
	slice := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

	fmt.Println(chart.ShuffleSlice(slice, 2))
	fmt.Println(chart.ShuffleSlice(slice, 3))
	fmt.Println(chart.ShuffleSlice(slice, 5))

}
Output:

[0 2 4 6 8 1 3 5 7 9]
[0 3 6 9 1 4 7 2 5 8]
[0 5 1 6 2 7 3 8 4 9]

Types ΒΆ

type Builder ΒΆ

type Builder[K cmp.Ordered, V Number] struct {
	// contains filtered or unexported fields
}

func New ΒΆ

func New[K cmp.Ordered, V Number]() *Builder[K, V]

func (*Builder[K, V]) Build ΒΆ

func (p *Builder[K, V]) Build() *Chart[K, V]

func (*Builder[K, V]) WidthDebug ΒΆ

func (p *Builder[K, V]) WidthDebug() *Builder[K, V]

func (*Builder[K, V]) WithBorderWidth ΒΆ

func (p *Builder[K, V]) WithBorderWidth(width float64) *Builder[K, V]

func (*Builder[K, V]) WithDisplayBorder ΒΆ

func (p *Builder[K, V]) WithDisplayBorder() *Builder[K, V]

func (*Builder[K, V]) WithSize ΒΆ

func (p *Builder[K, V]) WithSize(width, height float64) *Builder[K, V]

type Chart ΒΆ

type Chart[K cmp.Ordered, V Number] struct {
	Title string
	Fonts *Fonts

	Colors []color.Color
	// contains filtered or unexported fields
}

func (*Chart[K, V]) Column ΒΆ

func (p *Chart[K, V]) Column(name string, seq iter.Seq2[K, V])

func (*Chart[K, V]) WriteFile ΒΆ

func (p *Chart[K, V]) WriteFile(file string) error

type Fonts ΒΆ

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

func NewDefaultFonts ΒΆ

func NewDefaultFonts() *Fonts

func NewFonts ΒΆ

func NewFonts() *Fonts

func (*Fonts) Face ΒΆ

func (p *Fonts) Face(name string, size float64, args ...any) *canvas.FontFace

func (*Fonts) Font ΒΆ

func (p *Fonts) Font(name string) *canvas.FontFamily

func (*Fonts) Load ΒΆ

func (p *Fonts) Load(name, file string, style canvas.FontStyle) error

type Layout ΒΆ

type Layout struct {
	Size  canvas.Size
	Title canvas.Rect
	Main  canvas.Rect
	Chart canvas.Rect
}

func DefaultLayout ΒΆ

func DefaultLayout(width, height, borderWidth float64) *Layout

type Number ΒΆ

type Number interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64
}

Directories ΒΆ

Path Synopsis
_examples
border
nolint: mnd
nolint: mnd
line
nolint: mnd
nolint: mnd
line2
nolint: mnd
nolint: mnd
title
nolint: mnd
nolint: mnd

Jump to

Keyboard shortcuts

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