https://github.com/sndnv/asciichart
ASCII terminal line charts with no dependencies
https://github.com/sndnv/asciichart
ascii ascii-chart chart charting charting-library elixir elixir-lang plot terminal
Last synced: 2 months ago
JSON representation
ASCII terminal line charts with no dependencies
- Host: GitHub
- URL: https://github.com/sndnv/asciichart
- Owner: sndnv
- License: apache-2.0
- Created: 2018-08-10T13:57:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-06T09:05:27.000Z (over 1 year ago)
- Last Synced: 2025-03-23T02:04:48.260Z (3 months ago)
- Topics: ascii, ascii-chart, chart, charting, charting-library, elixir, elixir-lang, plot, terminal
- Language: Elixir
- Homepage:
- Size: 28.3 KB
- Stars: 21
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# asciichart
[](https://hex.pm/packages/asciichart) [](https://codecov.io/gh/sndnv/asciichart) []()
Terminal ASCII line charts in Elixir with no dependencies.
Ported to Elixir from [kroitor/asciichart](https://github.com/kroitor/asciichart)
## Install
Add `asciichart` to the list of dependencies in `mix.exs`:
```elixir
def deps do
[{:asciichart, "~> "}]
end
```## Usage
```elixir
{:ok, chart} = Asciichart.plot([1, 2, 3, 3, 2, 1])
chart |> IO.puts()# 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
- `charset` - a customizable character set. See `Asciichart.Charset`.
- `precision` - number of fractional digits to keep for floating-point values```elixir
{:ok, chart} = Asciichart.plot([1, 2, 5, 5, 4, 3, 2, 100, 0], height: 3, offset: 10, padding: "__")
chart |> IO.puts()# 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"}
```
If you want to change the character set, you can use a predefined one in `Asciichart.Charset` or create your own.
```elixir
{:ok, chart} = Asciichart.plot([1, 2, 5, 5, 4, 3, 2, 0], height: 5, charset: Asciichart.Charset.single_char("*"))
chart |> IO.puts()5.00 ┤ ***
3.75 ┤ * **
2.50 ┤ * **
1.25 ┤** **
0.00 ** *
```## Versioning
We use [SemVer](http://semver.org/) for versioning.## License
This project is licensed under the Apache License, Version 2.0 - see the [LICENSE](LICENSE) file for details> Copyright 2018 https://github.com/sndnv
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> See the License for the specific language governing permissions and
> limitations under the License.