termeter

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

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

Go to latest
Published: Nov 12, 2015 License: MIT Imports: 6 Imported by: 2

README

termeter

Visualize data in the terminal

Description

termeter can visualize data in the terminal. Data can be passed by pipe or file.

$  seq 100 | awk 'BEGIN{OFS="\t"; print "x","sin(x)","cos(x)"}{x=$1/10; print x,sin(x),cos(x)}' | termeter

screenshot01

You can even draw charts from streaming data.

$ seq 300 | awk 'BEGIN{OFS="\t"; print "x","sin(x)","cos(x)"}{x=$1/10; print x,sin(x),cos(x); system("sleep 0.1")}' | termeter

Installation

$ go get github.com/atsaki/termeter/cmd/termeter

Input Data

You can input data with stdin or file.

$ cat data.txt | termeter
$ termeter data.txt

termeter can accept tabular data like CSV. Delimiter character can be specified with option '-d DELIMITER'. Default is tab.

Chart types

termeter supports following chart types.

  • LINE
    • Plot values as line plot
  • COUNTER
    • Bar chart of frequencies
  • CDF
    • Cumulative distribution function

By default, termeter choose chart type automatically from second line of data. If value is numeric LINE is choosed. Otherwise, COUNTER is choosed.

You can specify chart type with option -t TYPESTRING. nth character of TYPESTRING corresponds to nth chart type. Following charcters can be used.

  • l: LINE
  • c: COUNTER
  • d: CDF
  • other: auto
Example of chart types
$ (echo "line counter cdf"; seq 1 1000 | awk '{x=int(6*rand())+1; print x,x,x}') | termeter -d " " -t lcd -S numerical

charttype

Use case

It is useful to draw chart of resouce in the terminal. You can use tools like dstat.

$ dstat --cpu --output dstat.log > /dev/null &
$ tail -f -n +7 dstat.log | termeter -d ,

License

MIT

Documentation

Index

Constants

View Source
const (
	LINE = iota
	COUNTER
	CDF
)

panel types

View Source
const (
	SORT_NONE = iota
	SORT_ALPHABETICAL
	SORT_NUMERICAL
)

sort mode of counter panel

View Source
const (
	HISTOGRAM_BIN_COUNT = 50
	LIST_WIDTH          = 30
	BUFFER_SIZE         = 1000
)

panel parameters

Variables

This section is empty.

Functions

func Render

func Render(box Box)

Types

type App

type App struct {
	*VBox
	// contains filtered or unexported fields
}

func NewApp

func NewApp() *App

func (*App) AddPanel

func (app *App) AddPanel(label string, panelType int, options map[string]string)

func (*App) GetPanel

func (app *App) GetPanel(i int) Panel

func (*App) Render

func (app *App) Render()

type BarChartWidget

type BarChartWidget struct {
	BarChart *termui.BarChart
}

func NewBarChartWidget

func NewBarChartWidget() *BarChartWidget

func (*BarChartWidget) Add

func (bc *BarChartWidget) Add(label string, freq int)

func (*BarChartWidget) Buffer

func (bc *BarChartWidget) Buffer() []termui.Point

func (*BarChartWidget) SetHeight

func (bc *BarChartWidget) SetHeight(h int)

func (*BarChartWidget) SetWidth

func (bc *BarChartWidget) SetWidth(w int)

func (*BarChartWidget) SetX

func (bc *BarChartWidget) SetX(x int)

func (*BarChartWidget) SetY

func (bc *BarChartWidget) SetY(y int)

func (*BarChartWidget) Update

func (bc *BarChartWidget) Update(labels []string, freqs []int)

type Box

type Box interface {
	GetWidth() int
	GetHeight() int
	SetWidth(w int)
	SetHeight(h int)
	Bufferers() []termui.Bufferer
	Render(x, y, w, h int)
}

type BoxBase

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

func (*BoxBase) GetHeight

func (bb *BoxBase) GetHeight() int

func (*BoxBase) GetWidth

func (bb *BoxBase) GetWidth() int

func (*BoxBase) SetHeight

func (bb *BoxBase) SetHeight(h int)

func (*BoxBase) SetWidth

func (bb *BoxBase) SetWidth(w int)

type CDFPanel

type CDFPanel struct {
	*PanelBase
	// contains filtered or unexported fields
}

func NewCDFPanel

func NewCDFPanel(label string) *CDFPanel

func (*CDFPanel) Add

func (p *CDFPanel) Add(x float64)

func (*CDFPanel) SetMode

func (p *CDFPanel) SetMode(mode string)

func (*CDFPanel) Update

func (p *CDFPanel) Update()

type CounterPanel

type CounterPanel struct {
	*PanelBase
	// contains filtered or unexported fields
}

func NewCounterPanel

func NewCounterPanel(label string) *CounterPanel

func (*CounterPanel) Add

func (p *CounterPanel) Add(label string)

func (*CounterPanel) AddLabel

func (p *CounterPanel) AddLabel(label string)

func (*CounterPanel) SetSortMode

func (p *CounterPanel) SetSortMode(mode int)

type HBox

type HBox struct {
	LayoutBoxBase
}

func NewHBox

func NewHBox() *HBox

func (*HBox) Render

func (hb *HBox) Render(x, y, w, h int)

type LayoutBox

type LayoutBox interface {
	Box
	AddBoxes(boxes ...Box)
}

type LayoutBoxBase

type LayoutBoxBase struct {
	BoxBase
	// contains filtered or unexported fields
}

func (*LayoutBoxBase) AddBoxes

func (lb *LayoutBoxBase) AddBoxes(boxes ...Box)

func (*LayoutBoxBase) Bufferers

func (lb *LayoutBoxBase) Bufferers() []termui.Bufferer

type LineChartPanel

type LineChartPanel struct {
	*PanelBase
	// contains filtered or unexported fields
}

func NewLineChartPanel

func NewLineChartPanel(label string) *LineChartPanel

func (*LineChartPanel) Add

func (p *LineChartPanel) Add(x float64, dataLabel string)

func (*LineChartPanel) SetMode

func (p *LineChartPanel) SetMode(mode string)

func (*LineChartPanel) Update

func (p *LineChartPanel) Update()

type LineChartWidget

type LineChartWidget struct {
	Data       *float64RingBuffer
	DataLabels *stringRingBuffer
	Mode       string
	LineChart  *termui.LineChart
}

func NewLineChartWidget

func NewLineChartWidget(bufsize int) *LineChartWidget

func (*LineChartWidget) Add

func (lc *LineChartWidget) Add(x float64, dataLabel string)

func (*LineChartWidget) Buffer

func (lc *LineChartWidget) Buffer() []termui.Point

func (*LineChartWidget) Clear

func (lc *LineChartWidget) Clear()

func (*LineChartWidget) SetHeight

func (lc *LineChartWidget) SetHeight(h int)

func (*LineChartWidget) SetWidth

func (lc *LineChartWidget) SetWidth(w int)

func (*LineChartWidget) SetX

func (lc *LineChartWidget) SetX(x int)

func (*LineChartWidget) SetY

func (lc *LineChartWidget) SetY(y int)

func (*LineChartWidget) Update

func (lc *LineChartWidget) Update(xs []float64, dataLabels []string)

type ListWidget

type ListWidget struct {
	List *termui.List
}

func NewListWidget

func NewListWidget() *ListWidget

func (*ListWidget) Add

func (ls *ListWidget) Add(items ...string)

func (*ListWidget) Buffer

func (ls *ListWidget) Buffer() []termui.Point

func (*ListWidget) SetHeight

func (ls *ListWidget) SetHeight(h int)

func (*ListWidget) SetWidth

func (ls *ListWidget) SetWidth(w int)

func (*ListWidget) SetX

func (ls *ListWidget) SetX(x int)

func (*ListWidget) SetY

func (ls *ListWidget) SetY(y int)

func (*ListWidget) Update

func (ls *ListWidget) Update(items []string)

type Panel

type Panel interface {
	LayoutBox
	SetWidget(w Widget)
	GetType() int
}

type PanelBase

type PanelBase struct {
	*HBox
	// contains filtered or unexported fields
}

func NewPanelBase

func NewPanelBase(label string) *PanelBase

func (*PanelBase) GetType

func (p *PanelBase) GetType() int

func (*PanelBase) SetWidget

func (p *PanelBase) SetWidget(w Widget)

type ParWidget

type ParWidget struct {
	Par *termui.Par
}

func NewParWidget

func NewParWidget() *ParWidget

func (*ParWidget) Buffer

func (p *ParWidget) Buffer() []termui.Point

func (*ParWidget) SetHeight

func (p *ParWidget) SetHeight(h int)

func (*ParWidget) SetWidth

func (p *ParWidget) SetWidth(w int)

func (*ParWidget) SetX

func (p *ParWidget) SetX(x int)

func (*ParWidget) SetY

func (p *ParWidget) SetY(y int)

func (*ParWidget) Update

func (p *ParWidget) Update(text string)

type VBox

type VBox struct {
	LayoutBoxBase
}

func NewVBox

func NewVBox() *VBox

func (*VBox) Render

func (vb *VBox) Render(x, y, w, h int)

type Widget

type Widget interface {
	SetX(x int)
	SetY(y int)
	SetWidth(w int)
	SetHeight(h int)
	Buffer() []termui.Point
}

type WidgetBox

type WidgetBox struct {
	BoxBase
	Widget Widget
}

func NewWidgetBox

func NewWidgetBox() *WidgetBox

func (*WidgetBox) Bufferers

func (wb *WidgetBox) Bufferers() []termui.Bufferer

func (*WidgetBox) Render

func (wb *WidgetBox) Render(x, y, w, h int)

func (*WidgetBox) SetWidget

func (wb *WidgetBox) SetWidget(w Widget)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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