Skip to content

Instantly share code, notes, and snippets.

@ndarville
Last active March 2, 2022 15:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ndarville/4525220 to your computer and use it in GitHub Desktop.
Save ndarville/4525220 to your computer and use it in GitHub Desktop.
Envisioning ASCII bar charts

ASCII Bar Charts

Basics

The four kinds of glyphs suggested are:

  • ░ (font/typeface-dependent, so may be invisible),
  • █,
  • ▄,

Now available in ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ — ▁▂▃▄▅▆▇█ — ( ), ▁, ▂, ▃, ▄, ▅, ▆, ▇, █

Examples

An chart for values 1, 2, 3, 4, 1+1:

As Code

    ▄ █ ░
▄ █ █ █ █

As Text

(Underscores to prevent Markdown from parsing the indentation.)

_ _ ▄ █ ░ ▄ █ █ █ █

Axes

Vertical

   ^
   |
25 |
   |
20 |
   |
15 |
   |
10 |
   |
 5 |
   +-------------------->

With bars:

   ^
10 |
   |    ▄ █ ░
 5 |▄ █ █ █ █
   +- - - - - - - - - - - ->
    J F M A M J J A S O N D

Horizontal

Multi-layer chart:

     0     5     10
Jan: ------|-------
Feb: ---|--
Mar: -------|----
Apr: -----|----
May: --|-
Jun: ----|---
Jul: --|-------------
Aug: ------------|---
Sep: ---|---
Oct: ---------|-
Nov: ------|--
Dec: ---|--
     0     5     10

No Axes (Sparklines)

▅▆▂▃▂▂▂▅▂▂▅▇▂▂▂▃▆▆▆▅▃▂▂▂▁▂▂▆▁▃

Using spark.

Caption

,---------------------.
|    Rise and Fall    | <- Note how the text is centred
| of the Roman Empire | <- Largest line of text gets one space of hor. padding
`---------------------'

Observations

  1. The chequered block is not visible in the code example, either because of
    • typeface
    • or the background colour
  2. Bar charts in plain text are a total faceplant
  3. The line height can creates problems such as
    • annoying vertical gutters
    • impossible equilateral vertical and horizontal lines and geometric objects ...
    • ... unless people conform to a specified font and line height

Additional

The bars are inherently imprecise, so what would be the best way to address this? Perhaps a Tuftian precision index should be included?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment