Documentation
¶
Index ¶
- Constants
- Variables
- func BgGreenS(s string) string
- func BgRedS(s string) string
- func BlueS(s string) string
- func BoldS(s string) string
- func ColorizeDist[T int | float32 | float64](s string, v T, points []T, colors []string) string
- func ColorizeMinMax[T int | float32 | float64](s string, v, min, max T, minC, maxC string) string
- func DimS(s string) string
- func GreenS(s string) string
- func HeaderTo(w io.StringWriter, title string)
- func RedS(s string) string
- func Spark(counts map[int]int, width int) string
- func SparkLine(vals []int, maxVal, width int) string
- func VolumeBar[T int | int32 | int64 | float32 | float64](v, max T, width int) string
- func YellowS(s string) string
- type Alignment
- type TablCol
- type TableWriter
Constants ¶
const ( Reset = "\033[0m" Red = "\033[91m" Green = "\033[92m" Yellow = "\033[93m" Blue = "\033[94m" Magenta = "\033[95m" Cyan = "\033[96m" Dim = "\033[2m" Bold = "\033[1m" BgRed = "\033[41m" BgGreen = "\033[42m" BgYellow = "\033[43m" )
Variables ¶
var EnableColor = os.Getenv("NO_COLOR") == ""
var SparkBlocks = []rune{' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
SparkBlocks are Unicode block characters for drawing sparklines, from empty (space) to full block. Levels 0..8.
Functions ¶
func ColorizeDist ¶ added in v0.1.9
ColorizeDist colorizes s based on which interval v falls into. points must be sorted ascending; colors must have len(points)+1 elements. colors[0]: v < points[0] colors[i]: points[i-1] <= v < points[i] colors[len(points)]: v >= points[len(points)-1]
func ColorizeMinMax ¶ added in v0.1.2
func HeaderTo ¶ added in v0.1.8
func HeaderTo(w io.StringWriter, title string)
func Spark ¶ added in v0.4.0
Spark renders a sparkline from a sparse bucket→count map. Each of the width positions maps to a SparkBlocks character whose level is proportional to its count relative to maxCount. Useful for rendering Probability Density Function (PDF) - X is value, Y is % of population.
func SparkLine ¶ added in v0.4.0
SparkLine renders a sparkline from a slice of values. Each value is mapped to a SparkBlocks character proportional to maxVal. The result is stretched to width characters.
Types ¶
type TableWriter ¶
type TableWriter struct {
Indent string
Cols []TablCol
Out interface {
WriteString(s string) (n int, err error)
}
}
TableWriter provides simple table formatting with ANSI color support. Values that are too long will get truncated into column width.
func (TableWriter) WriteHeader ¶
func (s TableWriter) WriteHeader()
func (TableWriter) WriteHeaderLine ¶
func (s TableWriter) WriteHeaderLine()
func (TableWriter) WriteRow ¶
func (s TableWriter) WriteRow(vs ...string)
func (TableWriter) WriteSubHeader ¶
func (s TableWriter) WriteSubHeader(vs ...string)