danielkrupinski / asciigraph

Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

asciigraph

Build status Go Report Card Coverage Status GoDoc License

Go package to make lightweight ASCII line graphs ╭┈╯.

https://user-images.githubusercontent.com/7895001/41509956-b1b2b3d0-7279-11e8-9d19-d7dea17d5e44.png

Installation

go get github.com/guptarohit/asciigraph

Usage

Basic graph

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}

    conf := map[string]interface{}{}

    graph := asciigraph.Plot(data, conf)

    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 ┤   ╰╯    ╰╯╰╯

Acknowledgement

This package is golang port of library asciichart written by @kroitor.

Contributing

Feel free to make a pull request! :octocat:

About

Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%