DRY Bar Chart
A DRY bar chart displays letter frequencies from a TSV dataset using ordinal and linear scales for x and y positioning. The visual encoding is abstracted into composed functions: value accessors, scale mappings, and data-to-display maps, avoiding repetition. Rendered in SVG with D3 v3, it draws steelblue rectangles whose heights reflect frequency percentages, and includes formatted axes with a "Frequency" label. The code separates concerns by defining xValue, xScale, xMap and yValue, yScale, yMap before binding data via `d3.tsv`.
AI-generated descriptionA variation of the example bar chart using a slightly more D.R.Y. style. The visual encoding is represented by two functions and their composition:
- The value accessor returns the value (or property) to encode for a given data object.
- The scale maps this value to a visual display encoding, such as a pixel position.
- The map function represents the composition value ○ scale, mapping from data to display.
Inspired by Andrew Winterman’s post, Tooling for the Lazy Programmer: DRYing up D3.