github.com/drhuffman12/ascii_bar_charter

ASCII character-based bar chart generator

1 stars
2 dependents
License: MIT

Nothing has been indexed for 1.0.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  ascii_bar_charter:
    github: drhuffman12/ascii_bar_charter
    version: ~> 1.0.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 1.0.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

ascii_bar_charter

Travis status: Travis

GitHub release

This is a ASCII character-based bar char generator, with optional value prefix (of given precision) and optional colorization (red/green gradations).

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      ascii_bar_charter:
        github: drhuffman12/ascii_bar_charter
        branch: master
  2. 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:

examples.png

Contributing

  1. Fork it (https://github.com/your-github-user/ascii_bar_charter/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors