Fork me on GitHub

Project Notes

Console Barcharts

Print barcharts to the console in ascii or with unicode block elements

Notes

I learned of the barcharts gem in rubyweekly #492.

It’s a pretty neat little utility for generating console barcharts.

Taking it for a quick test drive…

Running the Example

The Gemfile specifies the gem requirements. bundle install as usual.

$ gem install bundler && bundle install
$ ./example.rb
Books Published/Year. Source: https://en.wikipedia.org/wiki/Books_published_per_country_per_year
By Country (unsorted)  (n=1943551)
---------------------------------
  Australia       ( 1%) |  28234
  Brazil          ( 2%) | * 57473
  China           (22%) | *********** 440000
  France          ( 4%) | ** 77986
  Germany         ( 4%) | ** 93600
  India           ( 4%) | ** 90000
  Indonesia       ( 4%) | ** 89000
  Italy           ( 3%) | * 61966
  Iran            ( 3%) | * 72871
  Japan           ( 7%) | *** 139078
  Russia          ( 5%) | ** 101981
  South Korea     ( 3%) | * 63476
  Spain           ( 2%) | * 44000
  Taiwan          ( 1%) |  28084
  Turkey          ( 3%) | * 66890
  United Kingdom  ( 9%) | **** 184000
  United States   (15%) | ******* 304912
By Country (block chars, sorted)  (n=1943551)
---------------------------------
  China           (22%) | ▉▉▉▉▉▉▉▉▉▉▉▎ 440000
  United States   (15%) | ▉▉▉▉▉▉▉▉ 304912
  United Kingdom  ( 9%) | ▉▉▉▉▊ 184000
  Japan           ( 7%) | ▉▉▉▋ 139078
  Russia          ( 5%) | ▉▉▋ 101981
  Germany         ( 4%) | ▉▉▍ 93600
  India           ( 4%) | ▉▉▎ 90000
  Indonesia       ( 4%) | ▉▉▎ 89000
  France          ( 4%) | ▉▉▏ 77986
  Iran            ( 3%) | ▉▉ 72871
  Turkey          ( 3%) | ▉▊ 66890
  South Korea     ( 3%) | ▉▋ 63476
  Italy           ( 3%) | ▉▋ 61966
  Brazil          ( 2%) | ▉▍ 57473
  Spain           ( 2%) | ▉▏ 44000
  Australia       ( 1%) | ▊ 28234
  Taiwan          ( 1%) | ▊ 28084

example

Credits and References

About LCK#165 ruby
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.