chartbar

package
v0.30.49 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package chartbar 控制台绘制ascii柱状图

Index

Constants

This section is empty.

Variables

View Source
var DefaultCtx = NewCtx()

Functions

This section is empty.

Types

type Ctx added in v0.25.0

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

func NewCtx added in v0.25.0

func NewCtx(modOptions ...ModOption) *Ctx

func NewCtxWith added in v0.25.0

func NewCtxWith(ctx *Ctx, modOptions ...ModOption) *Ctx

NewCtxWith

在`ctx`参数基础上使用`modOptions`生成新的 Ctx

func (*Ctx) WithAnySlice added in v0.25.0

func (ctx *Ctx) WithAnySlice(a interface{}, iterateTransFn func(originItem interface{}) Item, modOptions ...ModOption) string

func (*Ctx) WithCsv added in v0.25.0

func (ctx *Ctx) WithCsv(filename string) (string, error)

func (*Ctx) WithItems added in v0.25.0

func (ctx *Ctx) WithItems(items []Item) string

WithItems

@param items: 注意,内部不会修改切片底层数据的值以及顺序

func (*Ctx) WithMap added in v0.25.0

func (ctx *Ctx) WithMap(m map[string]int) string

func (*Ctx) WithMapFloat added in v0.25.0

func (ctx *Ctx) WithMapFloat(m map[string]float64) string

type Item

type Item struct {
	Name string  // key
	Num  float64 // value
	// contains filtered or unexported fields
}

type ModOption added in v0.25.0

type ModOption func(option *Option)

type Option added in v0.22.0

type Option struct {
	MaxBarLength    int    // 柱状图形的最大长度
	DrawIconBlock   string // 柱状图实体绘制内容
	DrawIconPadding string // 柱状图空余部分绘制内容
	HideName        bool   // 是否隐藏图形旁边的Name字段
	HideNum         bool   // 是否隐藏图形旁边的Num字段

	Order          Order // 排序方式
	PrefixNumLimit int   // 只显示前`PrefixNumLimit`个元素,注意,可以和`SuffixNumLimit`同时使用
	SuffixNumLimit int   // 只显示后`SuffixNumLimit`个元素
}

type Order added in v0.22.0

type Order int
const (
	OrderOrigin    Order = iota + 1 // 原始序
	OrderAscCount                   // 按计数值升序排序
	OrderDescCount                  // 按计数值降序排序
	OrderAscName                    // 按字段名称升序排序
	OrderDescName                   // 按字段名称降序排序

	NoNumLimit = -1
)

Jump to

Keyboard shortcuts

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