/asciichart

Erlang asciichart port

Primary LanguageErlangThe UnlicenseUnlicense

asciichart

Terminal ASCII line charts in Erlang.

Terminal ASCII line charts in Elixir

Ported to Erlang from kroitor/asciichart based on Elixir port, made by sndnv.

Install

Add asciichart to the list of dependencies in rebar.config:

{deps, [
    {asciichart,
        {git, "https://github.com/4tyTwo/asciichart.git",
            {branch, master}
        }
    }
]}.

Usage

{ok, Chart} = asciichart:plot([1, 2, 3, 3, 2, 1]),
asciichart:print(Chart).

% should render as

3.00 ┤ ╭─╮
2.00 ┤╭╯ ╰╮
1.00 ┼╯   ╰

Options

One or more of the following settings can be provided:

  • offset - number of characters to set as the chart's (left) offset
  • height - adjusts the height of the chart
  • padding - one or more characters to use for the label's (left) padding
{ok, Chart} = asciichart:plot([1, 2, 5, 5, 4, 3, 2, 100, 0], #{height => 3, offset => 10, padding: <<"_">>}).
asciichart:print(Chart).

% should render as

       ╭─> label
    ------
    100.00    ┼      ╭╮
    _50.00    ┤      ││
    __0.00    ┼──────╯╰
    --
---- ╰─> label padding
 ╰─> remaining offset (without the label)

% Rendering of empty charts is not supported

asciichart:plot([])
{error, no_data}