Scales
Scales are functions that map a domain to a range. I know I keep saying that, but there really isn't much more to say.
The reason we use them is to avoid math. This makes our code shorter, easier to understand, and more robust, as mistakes in high-school mathematics are some of the hardest bugs to track down.
If you haven't spent 4 years just listening to mathematics at school, note that a function's domain includes the values for which it is defined (the input), and its range includes the values it returns.
The following figure is borrowed from Wikipedia:
Here, X is the domain, Y is the range, and the arrows are the functions. We need a bunch ...
Get D3.js: Cutting-edge Data Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.