Convert histogram into library object

Convert the histogram visualization from an effectively-standalone
procedural routine into a library object which can be used to generate
histograms from various input sources and for various output encodings.