Terminal ASCII line charts in Erlang.
Ported to Erlang from kroitor/asciichart based on Elixir port, made by sndnv.
Add asciichart
to the list of dependencies in rebar.config
:
{deps, [
{asciichart,
{git, "https://github.com/4tyTwo/asciichart.git",
{branch, master}
}
}
]}.
{ok, Chart} = asciichart:plot([1, 2, 3, 3, 2, 1]),
asciichart:print(Chart).
% should render as
3.00 ┤ ╭─╮
2.00 ┤╭╯ ╰╮
1.00 ┼╯ ╰
One or more of the following settings can be provided:
offset
- number of characters to set as the chart's (left) offsetheight
- adjusts the height of the chartpadding
- 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}