guptarohit / asciigraph

Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.
https://pkg.go.dev/github.com/guptarohit/asciigraph
BSD 3-Clause "New" or "Revised" License
2.64k stars 99 forks source link

Two options: ColorAbove and ColorBelow #38

Open perbu opened 1 year ago

perbu commented 1 year ago

Hi.

I've added some code to enable options to color the parts of the graph that is above/below a certain value. So this graph:

bilde

Is produced by the following code:

func main() {
    series := []float64{1, 2, 3, 4, 5, 4, 3, 2, 1}
    graph := asciigraph.Plot(series, asciigraph.Height(10),
        asciigraph.Width(50),
        asciigraph.Caption("A simple line graph"),
        asciigraph.ColorAbove(asciigraph.Red, 4.0),
        asciigraph.ColorBelow(asciigraph.DarkGreen, 2.0),
    )
    fmt.Println(graph)
}

Lemme know if you want me to contribute this in a proper manner. If so I'll but a bow on it and hand it over.

Cheers,

Per.

0x090909 commented 1 year ago

very helpful