Go package to make lightweight ASCII line graphs ╭┈╯.
go get github.com/guptarohit/asciigraph
package main
import (
"fmt"
"github.com/guptarohit/asciigraph"
)
func main() {
data := []float64{3, 4, 9, 6, 2, 4, 5, 8, 5, 10, 2, 7, 2, 5, 6}
graph := asciigraph.Plot(data)
fmt.Println(graph)
}
Running this example would render the following graph:
10.00 ┤ ╭╮ 9.00 ┤ ╭╮ ││ 8.00 ┤ ││ ╭╮││ 7.00 ┤ ││ ││││╭╮ 6.00 ┤ │╰╮ ││││││ ╭ 5.00 ┤ │ │ ╭╯╰╯│││╭╯ 4.00 ┤╭╯ │╭╯ ││││ 3.00 ┼╯ ││ ││││ 2.00 ┤ ╰╯ ╰╯╰╯
This package also brings a small utility for command line usage. Assuming
$GOPATH/bin
is in your $PATH
, simply go get
it then install CLI.
go install github.com/guptarohit/asciigraph/cmd/asciigraph
Feed it data points via stdin:
$ seq 1 72 | asciigraph -h 10 -c "plot data from stdin" 72.00 ┼ 65.55 ┤ ╭──── 59.09 ┤ ╭──────╯ 52.64 ┤ ╭──────╯ 46.18 ┤ ╭──────╯ 39.73 ┤ ╭──────╯ 33.27 ┤ ╭───────╯ 26.82 ┤ ╭──────╯ 20.36 ┤ ╭──────╯ 13.91 ┤ ╭──────╯ 7.45 ┤ ╭──────╯ 1.00 ┼──╯ plot data from stdin
This package is golang port of library asciichart written by @kroitor.
Feel free to make a pull request!