File: README.rst

package info (click to toggle)
golang-github-jesseduffield-asciigraph 0.4.1%2Bgit20190605.6d88e39-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 92 kB
  • sloc: makefile: 3
file content (122 lines) | stat: -rw-r--r-- 3,250 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.. -*-restructuredtext-*-

asciigraph
===========

.. image:: https://travis-ci.org/guptarohit/asciigraph.svg?branch=master
    :target: https://travis-ci.org/guptarohit/asciigraph
    :alt: Build status

.. image:: https://goreportcard.com/badge/github.com/guptarohit/asciigraph
    :target: https://goreportcard.com/report/github.com/guptarohit/asciigraph
    :alt: Go Report Card

.. image:: https://coveralls.io/repos/github/guptarohit/asciigraph/badge.svg?branch=master
    :target: https://coveralls.io/github/guptarohit/asciigraph?branch=master
    :alt: Coverage Status

.. image:: https://godoc.org/github.com/guptarohit/asciigraph?status.svg
    :target: https://godoc.org/github.com/guptarohit/asciigraph
    :alt: GoDoc

.. image:: https://img.shields.io/badge/licence-BSD-blue.svg
    :target: https://github.com/guptarohit/asciigraph/blob/master/LICENSE
    :alt: License

|

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

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


Installation
------------

::

    go get github.com/guptarohit/asciigraph


Usage
-----

Basic graph
^^^^^^^^^^^

.. code:: go

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

..


Command line interface
----------------------

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.

CLI Installation
^^^^^^^^^^^^^^^^

::

    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

..


Acknowledgement
----------------
This package is golang port of library `asciichart <https://github.com/kroitor/asciichart>`_ written by `@kroitor <https://github.com/kroitor>`_.

Contributing
------------

Feel free to make a pull request! :octocat: