ascii_bar_charter v1.4.1
ascii_bar_charter
This is a ASCII character-based bar char generator, with optional value prefix (of given precision) and optional colorization (red/green gradations).
Installation
-
Add the dependency to your
shard.yml
:dependencies: ascii_bar_charter: github: drhuffman12/ascii_bar_charter branch: master
-
Run
shards install
Usage
require "ascii_bar_charter"
Generate a B/W barchart of values with associated value as a prefix:
min = 0.0
max = 1.0
precision = 2.to_i8
in_bw = true
data = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
prefixed = true
reversed = false
charter = AsciiBarCharter.new(min, max, precision, in_bw, reversed)
plot = charter.plot(data, prefixed)
puts plot
This will (when in bw only) look like:
0.0_0.1▁0.2▂0.3▃0.4▄0.5▅0.6▆0.7▇0.8█0.9▉
_▁▂▃▄▅▆▇█▉
And, using custom colors/bars could look like:
.0.0'0.1'0.2░0.3░0.4▒0.5▒0.6▒0.7▓0.8▓0.9█
.''░░▒▒▒▓▓█
For other examples, see the tests.
Testing
(Optionally,) open a docker-compose
terminal:
docker-compose run app bash
Then run tests:
crystal spec
It should look like:
Contributing
- Fork it (https://github.com/your-github-user/ascii_bar_charter/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Daniel Huffman - creator and maintainer
Repository
ascii_bar_charter
Owner
Statistic
- 1
- 0
- 0
- 1
- 0
- over 3 years ago
- February 3, 2020
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 03:19:24 GMT
Languages