Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out how to do histograms #13

Open
zefhemel opened this issue Oct 2, 2017 · 1 comment
Open

Figure out how to do histograms #13

zefhemel opened this issue Oct 2, 2017 · 1 comment

Comments

@zefhemel
Copy link
Contributor

zefhemel commented Oct 2, 2017

One of the useful features of Kibana is the graph with number of hits for a given query over time, we need something like this in Ax. Maybe using something like: https://github.com/gizak/termui

@zefhemel zefhemel added this to To do in Egnyte Hackathon Apr 16, 2018
@zefhemel zefhemel changed the title Figure out how to do trending Figure out how to do histograms Apr 19, 2018
@romanlevin romanlevin moved this from To do to In progress in Egnyte Hackathon Apr 19, 2018
@zefhemel zefhemel moved this from In progress to To do in Egnyte Hackathon Apr 19, 2018
@zefhemel
Copy link
Contributor Author

I think this is not going to be worth the effort, nevertheless, here's some concept code I wrote to build a basic UI with bar charts.

package main

import (
	"fmt"

	ui "github.com/zefhemel/termui"
)

var debugLog *ui.List = nil

func main() {
	err := ui.Init()
	if err != nil {
		panic(err)
	}
	defer ui.Close()

	p := ui.NewList()
	p.Items = []string{"[Data](fg-blue) Sup", "[Data](fg-blue) Sup", "[Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup [Data](fg-blue) Sup[Data](fg-blue) Sup[Data](fg-blue) Sup[Data](fg-blue) Sup[Data](fg-blue) Sup[Data](fg-blue) Sup[Data](fg-blue) Sup"}
	p.BorderLabel = "Logs"
	p.Overflow = "wrap"
	p.Height = ui.TermHeight() - 15
	p.Width = ui.TermWidth()

	data := []int{1, 10, 5, 7}
	histogram := ui.NewBarChart()
	histogram.Height = 10
	histogram.BorderLabel = "Histogram"
	histogram.Data = data
	histogram.DataLabels = []string{"20:00", "21:00", "22:00", "23:00"}
	histogram.BarWidth = 5
	histogram.BarColor = ui.ColorYellow
	histogram.Width = ui.TermWidth()

	debugLog = ui.NewList()
	debugLog.Items = []string{"Sup"}
	debugLog.Height = 5
	debugLog.Width = ui.TermWidth()

	ui.Body.AddRows(
		ui.NewRow(
			ui.NewCol(12, 0, histogram)),
		ui.NewRow(
			ui.NewCol(12, 0, p)),
		ui.NewRow(
			ui.NewCol(12, 0, debugLog)))

	// calculate layout
	ui.Body.Align()

	ui.Render(ui.Body)

	ui.Handle("/sys/kbd/q", func(ui.Event) {
		// press q to quit
		ui.StopLoop()
	})

	ui.Handle("/sys/wnd/resize", func(ui.Event) {
		histogram.Width = ui.TermWidth()
		debugLog.Width = ui.TermWidth()
		p.Height = ui.TermHeight() - 15
		p.Width = ui.TermWidth()
		debug("Resized")
		ui.Render(ui.Body)
	})

	ui.Handle("/sys/kbd", func(e ui.Event) {
		debug(fmt.Sprintf("%+v", e))
	})

	ui.Loop() // block until StopLoop is called
}

func debug(s string) {
	debugLog.Items = append(debugLog.Items, s)
	ui.Render(ui.Body)
}

@zefhemel zefhemel removed their assignment Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant