本文整理汇总了Golang中github.com/gizak/termui.NewLineChart函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLineChart函数的具体用法?Golang NewLineChart怎么用?Golang NewLineChart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLineChart函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
//termui.UseTheme("helloworld")
sinps := (func() []float64 {
n := 220
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
lc0 := termui.NewLineChart()
lc0.BorderLabel = "braille-mode Line Chart"
lc0.Data = sinps
lc0.Width = 50
lc0.Height = 12
lc0.X = 0
lc0.Y = 0
lc0.AxesColor = termui.ColorWhite
lc0.LineColor = termui.ColorGreen | termui.AttrBold
lc1 := termui.NewLineChart()
lc1.BorderLabel = "dot-mode Line Chart"
lc1.Mode = "dot"
lc1.Data = sinps
lc1.Width = 26
lc1.Height = 12
lc1.X = 51
lc1.DotStyle = '+'
lc1.AxesColor = termui.ColorWhite
lc1.LineColor = termui.ColorYellow | termui.AttrBold
lc2 := termui.NewLineChart()
lc2.BorderLabel = "dot-mode Line Chart"
lc2.Mode = "dot"
lc2.Data = sinps[4:]
lc2.Width = 77
lc2.Height = 16
lc2.X = 0
lc2.Y = 12
lc2.AxesColor = termui.ColorWhite
lc2.LineColor = termui.ColorCyan | termui.AttrBold
termui.Render(lc0, lc1, lc2)
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}
开发者ID:missingdays,项目名称:termui,代码行数:57,代码来源:linechart.go
示例2: buildGraphs
func buildGraphs(res *wavefront.QueryResponse, height, width int, xVals, yVals []int) []ui.Bufferer {
graphs := make([]ui.Bufferer, maxGraphs)
for i, timeSeries := range res.TimeSeries[:maxGraphs] {
datapoints := make([]float64, len(timeSeries.DataPoints))
datalabels := make([]string, len(timeSeries.DataPoints))
for i, d := range timeSeries.DataPoints {
datapoints[i] = d[1]
datalabels[i] = time.Unix(int64(d[0]), 0).Format(time.Kitchen)
}
var label string
if timeSeries.Host != "" {
label = timeSeries.Host
} else {
label = res.Query
}
lc := ui.NewLineChart()
lc.BorderLabel = label
lc.Data = datapoints
lc.DataLabels = datalabels
lc.Width = width
lc.Height = height
lc.X = xVals[i]
lc.Y = yVals[i]
lc.AxesColor = ui.ColorWhite
lc.LineColor = ui.ColorYellow | ui.AttrBold
graphs[i] = lc
}
return graphs
}
开发者ID:spaceapegames,项目名称:go-wavefront,代码行数:35,代码来源:query.go
示例3: createDockerLineChart
func createDockerLineChart() *ui.LineChart {
lc := ui.NewLineChart()
lc.BorderLabel = "Container Numbers"
lc.Height = 10
lc.AxesColor = ui.ColorWhite
lc.LineColor = ui.ColorRed | ui.AttrBold
lc.Mode = "line"
return lc
}
开发者ID:byrnedo,项目名称:dockdash,代码行数:9,代码来源:view.go
示例4: NewCpuTabElems
func NewCpuTabElems(width int) *CpuTabElems {
lc := termui.NewLineChart()
lc.Width = width
lc.Height = 12
lc.X = 0
lc.Mode = "dot"
lc.Border.Label = "CPU"
return &CpuTabElems{GMap: make(map[string]*termui.Gauge),
LChart: lc}
}
开发者ID:himanshugpt,项目名称:termui,代码行数:10,代码来源:ttop.go
示例5: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
sinps := (func() []float64 {
n := 220
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
p := termui.NewPar(":PRESS q or Esc TO QUIT DEMO Hello World")
p.Height = 3
p.Width = 50
p.TextFgColor = termui.ColorWhite
p.BorderLabel = "Hello-World"
p.BorderFg = termui.ColorCyan
lc1 := termui.NewLineChart()
lc1.BorderLabel = "dot-mode Line Chart"
lc1.Mode = "dot"
lc1.Data = sinps
lc1.Width = 26
lc1.Height = 12
lc1.X = 51
lc1.DotStyle = '+'
lc1.AxesColor = termui.ColorWhite
lc1.LineColor = termui.ColorYellow | termui.AttrBold
g0 := termui.NewGauge()
g0.Percent = 40
g0.Width = 50
g0.Height = 3
g0.Y = 3
g0.BorderLabel = "Slim Gauge"
g0.BarColor = termui.ColorRed
g0.BorderFg = termui.ColorWhite
g0.BorderLabelFg = termui.ColorCyan
termui.Render(p, g0, lc1)
termui.Handle("/sys", func(e termui.Event) {
k, ok := e.Data.(termui.EvtKbd)
if ok && (k.KeyStr == "q" || k.KeyStr == "<escape>") {
termui.StopLoop()
}
})
termui.Loop()
}
开发者ID:VonC,项目名称:hello-world-go,代码行数:55,代码来源:main.go
示例6: createChart
// createChart creates an empty line chart with the default configs.
func createChart(height int) *termui.LineChart {
chart := termui.NewLineChart()
if runtime.GOOS == "windows" {
chart.Mode = "dot"
}
chart.DataLabels = []string{""}
chart.Height = height
chart.AxesColor = termui.ColorWhite
chart.PaddingBottom = -2
chart.Border.LabelFgColor = chart.Border.FgColor | termui.AttrBold
chart.Border.FgColor = chart.Border.BgColor
return chart
}
开发者ID:j4ustin,项目名称:go-ethereum,代码行数:16,代码来源:monitorcmd.go
示例7: main
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
sinps := (func() []float64 {
n := 400
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
sinpsint := (func() []int {
ps := make([]int, len(sinps))
for i, v := range sinps {
ps[i] = int(100*v + 10)
}
return ps
})()
// ui.UseTheme("helloworld")
spark := ui.Sparkline{}
spark.Height = 8
spdata := sinpsint
spark.Data = spdata[:100]
spark.LineColor = ui.ColorCyan
spark.TitleColor = ui.ColorWhite
sp := ui.NewSparklines(spark)
sp.Height = 11
sp.Border.Label = "Sparkline"
lc := ui.NewLineChart()
lc.Border.Label = "braille-mode Line Chart"
lc.Data = sinps
lc.Height = 11
lc.AxesColor = ui.ColorWhite
lc.LineColor = ui.ColorYellow | ui.AttrBold
gs := make([]*ui.Gauge, 3)
for i := range gs {
gs[i] = ui.NewGauge()
gs[i].Height = 2
gs[i].HasBorder = false
gs[i].Percent = i * 10
gs[i].PaddingBottom = 1
gs[i].BarColor = ui.ColorRed
}
ls := ui.NewList()
ls.HasBorder = false
ls.Items = []string{
"[1] Downloading File 1",
"", // == \newline
"[2] Downloading File 2",
"",
"[3] Uploading File 3",
}
ls.Height = 5
par := ui.NewPar("<> This row has 3 columns\n<- Widgets can be stacked up like left side\n<- Stacked widgets are treated as a single widget")
par.Height = 5
par.Border.Label = "Demonstration"
// build layout
ui.Body.AddRows(
ui.NewRow(
ui.NewCol(6, 0, sp),
ui.NewCol(6, 0, lc)),
ui.NewRow(
ui.NewCol(3, 0, ls),
ui.NewCol(3, 0, gs[0], gs[1], gs[2]),
ui.NewCol(6, 0, par)))
// calculate layout
ui.Body.Align()
done := make(chan bool)
redraw := make(chan bool)
/*
update := func() {
for i := 0; i < 103; i++ {
for _, g := range gs {
g.Percent = (g.Percent + 3) % 100
}
sp.Lines[0].Data = spdata[:100+i]
lc.Data = sinps[2*i:]
time.Sleep(time.Second / 2)
redraw <- true
}
done <- true
}
*/
//.........这里部分代码省略.........
开发者ID:arscan,项目名称:gosf,代码行数:101,代码来源:main.go
示例8: main
func main() {
// Init
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
// Theme Setting
ui.UseTheme("helloworld")
// Setup the CPU Gauge
cpuGauge := ui.NewGauge()
cpuGauge.Height = 2
cpuGauge.BarColor = ui.ColorRed
cpuGauge.HasBorder = false
cpuGauge.PaddingBottom = 1
go UpdateGenericGauge(cpuGauge, GetCPUPercentage)
// Setup the RAM Gauge
ramGauge := ui.NewGauge()
ramGauge.Height = 2
ramGauge.BarColor = ui.ColorGreen
ramGauge.HasBorder = false
ramGauge.PaddingBottom = 1
go UpdateGenericGauge(ramGauge, GetRAMPercentage)
// Setup the Label list
ls := ui.NewList()
ls.HasBorder = false
ls.Items = []string{
"CPU",
"",
"RAM",
}
ls.Height = 5
// Setup the CPU Line Chart
cpuLineChart := ui.NewLineChart()
cpuLineChart.Width = 50
cpuLineChart.Height = 11
cpuLineChart.Border.Label = "CPU Usage"
cpuLineChart.AxesColor = ui.ColorWhite
cpuLineChart.LineColor = ui.ColorGreen | ui.AttrBold
go UpdateGenericChart(cpuLineChart, GetCPUPercentage)
// Setup the RAM Line Chart
ramLineChart := ui.NewLineChart()
ramLineChart.Width = 50
ramLineChart.Height = 11
ramLineChart.Border.Label = "RAM Usage"
ramLineChart.AxesColor = ui.ColorWhite
ramLineChart.LineColor = ui.ColorGreen | ui.AttrBold
go UpdateGenericChart(ramLineChart, GetRAMPercentage)
// Setup the layout
ui.Body.AddRows(
ui.NewRow(
ui.NewCol(3, 0, cpuGauge, ramGauge),
ui.NewCol(3, 0, ls),
),
ui.NewRow(
ui.NewCol(6, 0, cpuLineChart),
ui.NewCol(6, 0, ramLineChart),
),
)
// Align
ui.Body.Align()
// Create the event polling system
evt := make(chan tm.Event)
go func() {
for {
evt <- tm.PollEvent()
}
}()
for {
select {
case e := <-evt:
if e.Type == tm.EventKey && e.Ch == 'q' {
return
}
if e.Type == tm.EventResize {
ui.Body.Width = ui.TermWidth()
ui.Body.Align()
}
default:
ui.Render(ui.Body)
time.Sleep(time.Second / 2)
}
}
}
开发者ID:yotixify,项目名称:termui-resources,代码行数:94,代码来源:main.go
示例9: main
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
ui.UseTheme("helloworld")
p := ui.NewPar(":PRESS q TO QUIT DEMO")
p.Height = 3
p.Width = 50
p.Border.Label = "Text Box"
strs := []string{"[0] gizak/termui", "[1] editbox.go", "[2] iterrupt.go", "[3] keyboard.go", "[4] output.go", "[5] random_out.go", "[6] dashboard.go", "[7] nsf/termbox-go"}
list := ui.NewList()
list.Items = strs
list.Border.Label = "List"
list.Height = 7
list.Width = 25
list.Y = 4
g := ui.NewGauge()
g.Percent = 50
g.Width = 50
g.Height = 3
g.Y = 11
g.Border.Label = "Gauge"
spark := ui.NewSparkline()
spark.Title = "srv 0:"
spdata := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6}
spark.Data = spdata
spark1 := ui.NewSparkline()
spark1.Title = "srv 1:"
spark1.Data = spdata
sp := ui.NewSparklines(spark, spark1)
sp.Width = 25
sp.Height = 7
sp.Border.Label = "Sparkline"
sp.Y = 4
sp.X = 25
lc := ui.NewLineChart()
sinps := (func() []float64 {
n := 100
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/4)
}
return ps
})()
lc.Border.Label = "Line Chart"
lc.Data = sinps
lc.Width = 50
lc.Height = 11
lc.X = 0
lc.Y = 14
lc.Mode = "dot"
bc := ui.NewBarChart()
bcdata := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
bc.Border.Label = "Bar Chart"
bc.Width = 26
bc.Height = 10
bc.X = 51
bc.Y = 0
bc.DataLabels = bclabels
lc1 := ui.NewLineChart()
lc1.Border.Label = "Line Chart"
rndwalk := (func() []float64 {
n := 150
d := make([]float64, n)
for i := 1; i < n; i++ {
if i < 20 {
d[i] = d[i-1] + 0.01
}
if i > 20 {
d[i] = d[i-1] - 0.05
}
}
return d
})()
lc1.Data = rndwalk
lc1.Width = 26
lc1.Height = 11
lc1.X = 51
lc1.Y = 14
p1 := ui.NewPar("Hey!\nI am a borderless block!")
p1.HasBorder = false
p1.Width = 26
p1.Height = 2
p1.X = 52
p1.Y = 11
//.........这里部分代码省略.........
开发者ID:himanshugpt,项目名称:termui,代码行数:101,代码来源:theme.go
示例10: main
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
p := ui.NewPar(":PRESS q TO QUIT DEMO")
p.Height = 3
p.Width = 50
p.TextFgColor = ui.ColorWhite
p.Border.Label = "Text Box"
p.Border.FgColor = ui.ColorCyan
strs := []string{"[0] gizak/termui", "[1] editbox.go", "[2] iterrupt.go", "[3] keyboard.go", "[4] output.go", "[5] random_out.go", "[6] dashboard.go", "[7] nsf/termbox-go"}
list := ui.NewList()
list.Items = strs
list.ItemFgColor = ui.ColorYellow
list.Border.Label = "List"
list.Height = 7
list.Width = 25
list.Y = 4
g := ui.NewGauge()
g.Percent = 50
g.Width = 50
g.Height = 3
g.Y = 11
g.Border.Label = "Gauge"
g.BarColor = ui.ColorRed
g.Border.FgColor = ui.ColorWhite
g.Border.LabelFgColor = ui.ColorCyan
spark := ui.Sparkline{}
spark.Height = 1
spark.Title = "srv 0:"
spdata := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6}
spark.Data = spdata
spark.LineColor = ui.ColorCyan
spark.TitleColor = ui.ColorWhite
spark1 := ui.Sparkline{}
spark1.Height = 1
spark1.Title = "srv 1:"
spark1.Data = spdata
spark1.TitleColor = ui.ColorWhite
spark1.LineColor = ui.ColorRed
sp := ui.NewSparklines(spark, spark1)
sp.Width = 25
sp.Height = 7
sp.Border.Label = "Sparkline"
sp.Y = 4
sp.X = 25
sinps := (func() []float64 {
n := 220
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
lc := ui.NewLineChart()
lc.Border.Label = "dot-mode Line Chart"
lc.Data = sinps
lc.Width = 50
lc.Height = 11
lc.X = 0
lc.Y = 14
lc.AxesColor = ui.ColorWhite
lc.LineColor = ui.ColorRed | ui.AttrBold
lc.Mode = "dot"
bc := ui.NewBarChart()
bcdata := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
bc.Border.Label = "Bar Chart"
bc.Width = 26
bc.Height = 10
bc.X = 51
bc.Y = 0
bc.DataLabels = bclabels
bc.BarColor = ui.ColorGreen
bc.NumColor = ui.ColorBlack
lc1 := ui.NewLineChart()
lc1.Border.Label = "braille-mode Line Chart"
lc1.Data = sinps
lc1.Width = 26
lc1.Height = 11
lc1.X = 51
lc1.Y = 14
lc1.AxesColor = ui.ColorWhite
lc1.LineColor = ui.ColorYellow | ui.AttrBold
p1 := ui.NewPar("Hey!\nI am a borderless block!")
p1.HasBorder = false
p1.Width = 26
//.........这里部分代码省略.........
开发者ID:davidwadden,项目名称:lattice-release,代码行数:101,代码来源:dashboard.go
示例11: runTestSequence
func (sc *sparkyClient) runTestSequence() {
// First, we need to build the widgets on our screen.
// Build our title box
titleBox := termui.NewPar("──────[ sparkyfish ]────────────────────────────────────────")
titleBox.Height = 1
titleBox.Width = 60
titleBox.Y = 0
titleBox.Border = false
titleBox.TextFgColor = termui.ColorWhite | termui.AttrBold
// Build the server name/location banner line
bannerBox := termui.NewPar("")
bannerBox.Height = 1
bannerBox.Width = 60
bannerBox.Y = 1
bannerBox.Border = false
bannerBox.TextFgColor = termui.ColorRed | termui.AttrBold
// Build a download graph widget
dlGraph := termui.NewLineChart()
dlGraph.BorderLabel = " Download Speed (Mbit/s)"
dlGraph.Data = []float64{0}
dlGraph.Width = 30
dlGraph.Height = 12
dlGraph.PaddingTop = 1
dlGraph.X = 0
dlGraph.Y = 6
// Windows Command Prompt doesn't support our Unicode characters with the default font
if runtime.GOOS == "windows" {
dlGraph.Mode = "dot"
dlGraph.DotStyle = '+'
}
dlGraph.AxesColor = termui.ColorWhite
dlGraph.LineColor = termui.ColorGreen | termui.AttrBold
// Build an upload graph widget
ulGraph := termui.NewLineChart()
ulGraph.BorderLabel = " Upload Speed (Mbit/s)"
ulGraph.Data = []float64{0}
ulGraph.Width = 30
ulGraph.Height = 12
ulGraph.PaddingTop = 1
ulGraph.X = 30
ulGraph.Y = 6
// Windows Command Prompt doesn't support our Unicode characters with the default font
if runtime.GOOS == "windows" {
ulGraph.Mode = "dot"
ulGraph.DotStyle = '+'
}
ulGraph.AxesColor = termui.ColorWhite
ulGraph.LineColor = termui.ColorGreen | termui.AttrBold
latencyGraph := termui.NewSparkline()
latencyGraph.LineColor = termui.ColorCyan
latencyGraph.Height = 3
latencyGroup := termui.NewSparklines(latencyGraph)
latencyGroup.Y = 3
latencyGroup.Height = 3
latencyGroup.Width = 30
latencyGroup.Border = false
latencyGroup.Lines[0].Data = []int{0}
latencyTitle := termui.NewPar("Latency")
latencyTitle.Height = 1
latencyTitle.Width = 30
latencyTitle.Border = false
latencyTitle.TextFgColor = termui.ColorGreen
latencyTitle.Y = 2
latencyStats := termui.NewPar("")
latencyStats.Height = 4
latencyStats.Width = 30
latencyStats.X = 32
latencyStats.Y = 2
latencyStats.Border = false
latencyStats.TextFgColor = termui.ColorWhite | termui.AttrBold
latencyStats.Text = "Last: 30ms\nMin: 2ms\nMax: 34ms"
// Build a stats summary widget
statsSummary := termui.NewPar("")
statsSummary.Height = 7
statsSummary.Width = 60
statsSummary.Y = 18
statsSummary.BorderLabel = " Throughput Summary "
statsSummary.Text = fmt.Sprintf("DOWNLOAD \nCurrent: -- Mbit/s\tMax: --\tAvg: --\n\nUPLOAD\nCurrent: -- Mbit/s\tMax: --\tAvg: --")
statsSummary.TextFgColor = termui.ColorWhite | termui.AttrBold
// Build out progress gauge widget
progress := termui.NewGauge()
progress.Percent = 40
progress.Width = 60
progress.Height = 3
progress.Y = 25
progress.X = 0
progress.Border = true
progress.BorderLabel = " Test Progress "
progress.Percent = 0
progress.BarColor = termui.ColorRed
//.........这里部分代码省略.........
开发者ID:mephux,项目名称:sparkyfish,代码行数:101,代码来源:sparkyfish-cli.go
示例12: main
func main() {
if err := ui.Init(); err != nil {
panic(err)
}
defer ui.Close()
p := ui.NewPar(":PRESS q TO QUIT DEMO")
p.Height = 3
p.Width = 50
p.TextFgColor = ui.ColorWhite
p.BorderLabel = "Text Box"
p.BorderFg = ui.ColorCyan
p.Handle("/timer/1s", func(e ui.Event) {
cnt := e.Data.(ui.EvtTimer)
if cnt.Count%2 == 0 {
p.TextFgColor = ui.ColorRed
} else {
p.TextFgColor = ui.ColorWhite
}
})
strs := []string{"[0] gizak/termui", "[1] editbox.go", "[2] iterrupt.go", "[3] keyboard.go", "[4] output.go", "[5] random_out.go", "[6] dashboard.go", "[7] nsf/termbox-go"}
list := ui.NewList()
list.Items = strs
list.ItemFgColor = ui.ColorYellow
list.BorderLabel = "List"
list.Height = 7
list.Width = 25
list.Y = 4
g := ui.NewGauge()
g.Percent = 50
g.Width = 50
g.Height = 3
g.Y = 11
g.BorderLabel = "Gauge"
g.BarColor = ui.ColorRed
g.BorderFg = ui.ColorWhite
g.BorderLabelFg = ui.ColorCyan
spark := ui.Sparkline{}
spark.Height = 1
spark.Title = "srv 0:"
spdata := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6}
spark.Data = spdata
spark.LineColor = ui.ColorCyan
spark.TitleColor = ui.ColorWhite
spark1 := ui.Sparkline{}
spark1.Height = 1
spark1.Title = "srv 1:"
spark1.Data = spdata
spark1.TitleColor = ui.ColorWhite
spark1.LineColor = ui.ColorRed
sp := ui.NewSparklines(spark, spark1)
sp.Width = 25
sp.Height = 7
sp.BorderLabel = "Sparkline"
sp.Y = 4
sp.X = 25
sinps := (func() []float64 {
n := 220
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
lc := ui.NewLineChart()
lc.BorderLabel = "dot-mode Line Chart"
lc.Data = sinps
lc.Width = 50
lc.Height = 11
lc.X = 0
lc.Y = 14
lc.AxesColor = ui.ColorWhite
lc.LineColor = ui.ColorRed | ui.AttrBold
lc.Mode = "dot"
bc := ui.NewBarChart()
bcdata := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
bc.BorderLabel = "Bar Chart"
bc.Width = 26
bc.Height = 10
bc.X = 51
bc.Y = 0
bc.DataLabels = bclabels
bc.BarColor = ui.ColorGreen
bc.NumColor = ui.ColorBlack
lc1 := ui.NewLineChart()
lc1.BorderLabel = "braille-mode Line Chart"
lc1.Data = sinps
lc1.Width = 26
lc1.Height = 11
lc1.X = 51
//.........这里部分代码省略.........
开发者ID:missingdays,项目名称:termui,代码行数:101,代码来源:dashboard.go
示例13: main
func main() {
if err := ui.Init(); err != nil {
panic(err)
}
defer ui.Close()
sinps := (func() []float64 {
n := 400
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
sinpsint := (func() []int {
ps := make([]int, len(sinps))
for i, v := range sinps {
ps[i] = int(100*v + 10)
}
return ps
})()
spark := ui.Sparkline{}
spark.Height = 8
spdata := sinpsint
spark.Data = spdata[:100]
spark.LineColor = ui.ColorCyan
spark.TitleColor = ui.ColorWhite
sp := ui.NewSparklines(spark)
sp.Height = 11
sp.BorderLabel = "Sparkline"
lc := ui.NewLineChart()
lc.BorderLabel = "braille-mode Line Chart"
lc.Data = sinps
lc.Height = 11
lc.AxesColor = ui.ColorWhite
lc.LineColor = ui.ColorYellow | ui.AttrBold
gs := make([]*ui.Gauge, 3)
for i := range gs {
gs[i] = ui.NewGauge()
//gs[i].LabelAlign = ui.AlignCenter
gs[i].Height = 2
gs[i].Border = false
gs[i].Percent = i * 10
gs[i].PaddingBottom = 1
gs[i].BarColor = ui.ColorRed
}
ls := ui.NewList()
ls.Border = false
ls.Items = []string{
"[1] Downloading File 1",
"", // == \newline
"[2] Downloading File 2",
"",
"[3] Uploading File 3",
}
ls.Height = 5
par := ui.NewPar("<> This row has 3 columns\n<- Widgets can be stacked up like left side\n<- Stacked widgets are treated as a single widget")
par.Height = 5
par.BorderLabel = "Demonstration"
// build layout
ui.Body.AddRows(
ui.NewRow(
ui.NewCol(6, 0, sp),
ui.NewCol(6, 0, lc)),
ui.NewRow(
ui.NewCol(3, 0, ls),
ui.NewCol(3, 0, gs[0], gs[1], gs[2]),
ui.NewCol(6, 0, par)))
// calculate layout
ui.Body.Align()
ui.Render(ui.Body)
ui.Handle("/sys/kbd/q", func(ui.Event) {
ui.StopLoop()
})
ui.Handle("/timer/1s", func(e ui.Event) {
t := e.Data.(ui.EvtTimer)
i := t.Count
if i > 103 {
ui.StopLoop()
return
}
for _, g := range gs {
g.Percent = (g.Percent + 3) % 100
}
sp.Lines[0].Data = spdata[:100+i]
lc.Data = sinps[2*i:]
ui.Render(ui.Body)
})
//.........这里部分代码省略.........
开发者ID:himanshugpt,项目名称:termui,代码行数:101,代码来源:grid.go
示例14: Draw
// func Draw(data reg.New) {
func Draw(model reg.New, datasource string) {
if datasource == "stdin" {
statheader = fmt.Sprintf("Statistics (File: Command line entry)")
} else {
statheader = fmt.Sprintf("Statistics (File: %s)", datasource)
}
if err := ui.Init(); err != nil {
panic(err)
}
defer ui.Close()
//Main data plot
lc := ui.NewLineChart()
lc.BorderLabel = "Main plot. Hit 'q' to exit. Drag to resize."
lc.Data = []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0.2, 0.1, 0.4, 0.33, 12.23}
lc.Mode = "dot"
lc.Height = 15
lc.AxesColor = ui.ColorWhite
lc.LineColor = ui.ColorRed | ui.AttrBold
//Residual plots
rp0 := ui.NewLineChart()
rp0.BorderLabel = "Residual 1"
rp0.Data = []float64{1, 2, 3, 4, 5, 6, 7, 8}
rp0.Mode = "dot"
rp0.Height = 15
rp0.AxesColor = ui.ColorWhite
rp0.LineColor = ui.ColorRed | ui.AttrBold
//Display statistics
// eq, conf, sd, rgc, intcp
// axis lable and axis scale
xlab := str("X axis: %s", model.Xlabel)
ylab := str("Y axis: %s", model.Ylabel)
eqxy := str("Equation(XonY): %s", model.Equation("XonY"))
eqyx := str("Equation(YonX): %s", model.Equation("YonX"))
conf := str("Confidence: %0.2f %%", model.Conf())
sdx := str("StdDev(X): %0.2f", model.SdX())
sdy := str("StdDev(Y): %0.2f", model.SdY())
bxy := str("RegCof(xy): %0.2f", model.Bxy())
byx := str("RegCof(yx): %0.2f", model.Byx())
cov := str("Covariance: %0.2f", model.Covariance())
ix, iy := model.Intersect()
icept := fmt.Sprintf("Intercept: %0.2f, %0.2f", ix, iy)
stats := []string{
xlab, ylab, eqxy, eqyx,
conf, sdx, sdy, bxy,
byx, cov, icept,
}
lst := ui.NewList()
lst.Items = stats // slice
lst.Height = 13
lst.Width = 30
lst.Y = 0
lst.BorderLabel = statheader
lst.ItemFgColor = ui.ColorWhite
ui.Body.AddRows(ui.NewRow(ui.NewCol(8, 0, lc), ui.NewCol(4, 0, rp0)), ui.NewRow(ui.NewCol(12, 0, lst)))
// ui.Body.AddRows(ui.NewRow(ui.NewCol(8,0,rp0)))
ui.Body.Align()
ui.Render(ui.Body)
ui.Handle("/sys/kbd/q", func(ui.Event) {
ui.StopLoop()
})
ui.Handle("sys/wnd/resize", func(e ui.Event) {
ui.Body.Width = ui.TermWidth()
ui.Body.Align()
ui.Render(ui.Body)
})
ui.Loop()
}
开发者ID:enodev0,项目名称:rat,代码行数:79,代码来源:vplot.go
示例15: main
//.........这里部分代码省略.........
se6_2.BorderFg = tui.ColorYellow
se6_2.BorderLabelFg = tui.ColorWhite
se6_2.Width = tui.TermWidth()
se6_2.Height = (tui.TermHeight() / 2) - (pr_th + g_h)
se6_2.Y = pr_th + se6_1.Height
// Slide 7
txtlst7 := "Widgets - Lists\n\no List - A text list\n\n"
txtlst7 += "o Text Lists\n\n"
txtlst7 += " tl := termui.NewList()\n"
txtlst7 += " tl.Items = textlist\n"
se7_2lst := []string{
"* List Elems",
"* Are Just",
"* Lists of",
"* Strings",
"* [and support](fg-blue)",
"* [colors](fg-green,bg-black)"}
se7_1 := tui.NewPar(txtlst7)
se7_1.Width = tui.TermWidth()
se7_1.Height = (tui.TermHeight() / 2) - (pr_th + g_h)
se7_1.Y = pr_th
se7_2 := tui.NewList()
se7_2.Items = se7_2lst
se7_2.BorderFg = tui.ColorYellow
se7_2.BorderLabelFg = tui.ColorWhite
se7_2.Width = tui.TermWidth()
se7_2.Height = (tui.TermHeight() / 2) - (pr_th + g_h)
se7_2.Y = pr_th + se7_1.Height
// Slide 8
txtlst8 := "Widgets - Line Charts\n\n"
txtlst8 += "o Draw linecharts\n\n"
txtlst8 += " lc := termui.NewLineChart()\n"
txtlst8 += " lc.Data = cosdata"
se8_1 := tui.NewPar(txtlst8)
se8_1.Width = tui.TermWidth()
se8_1.Height = (tui.TermHeight() / 2) - (pr_th + g_h)
se8_1.Y = pr_th
se8_2 := tui.NewLineChart()
se8_2.Data = cosData()
se8_2.BorderFg = tui.ColorYellow
se8_2.BorderLabelFg = tui.ColorWhite
se8_2.Width = tui.TermWidth()
se8_2.Height = (tui.TermHeight() / 2) - (pr_th + g_h)
se8_2.Y = pr_th + se8_1.Height
// Slide 9
txtlst9 := "Widgets - Bar Charts\n\n"
txtlst9 += "o Draw bar charts\n\n"
txtlst9 += " data := []int{4, 5, 6, 7, 8, 6, 5}\n"
txtlst9 += " bc := termui.NewBarChart()\n"
txtlst9 += " bc.Data = data"
se9_1 := tui.NewPar(txtlst9)
se9_1.Width = tui.TermWidth()
se9_1.Height = (tui.TermHeight() / 2) - (pr_th + g_h)
se9_1.Y = pr_th
se9_2 := tui.NewBarChart()
se9_2.Data = []int{4, 5, 6, 7, 8, 6, 5}
se9_2.DataLabels = []string{"S0", "S1", "S2", "S3", "S4", "S5", "S6", "S7"}
se9_2.BorderFg = tui.ColorYellow
se9_2.BorderLabelFg = tui.ColorWhite
se9_2.Width = tui.TermWidth()
se9_2.Height = (tui.TermHeight() / 2) - (pr_th + g_h)
se9_2.Y = pr_th + se9_1.Height
开发者ID:hoanga,项目名称:gohavefun,代码行数:66,代码来源:prez.go
示例16: init
import (
"flag"
"log"
"time"
"runtime"
"github.com/gizak/termui"
"github.com/vibhavp/memstats/internal/fetch"
)
var (
target = flag.String("target", "http://localhost:6060", "target link")
//boxes
heapAlloc = termui.NewLineChart()
heapObjects = termui.NewLineChart()
gcPause = termui.NewLineChart()
)
func init() {
heapAlloc.BorderLabel = "bytes allocated and not yet freed"
heapObjects.BorderLabel = "total number of allocated objects"
gcPause.BorderLabel = "GC Pause"
gcPause.Height = 50
gcPause.Width = 66
heapAlloc.Height = 50
heapAlloc.Width = 66
heapAlloc.X = 67
开发者ID:vibhavp,项目名称:memstats,代码行数:30,代码来源:memstats.go
注:本文中的github.com/gizak/termui.NewLineChart函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论