Introduction
As a data visualization developer, one of the key tasks that you will need to perform over and over is to map values from your data domain to your visual domain; for example, mapping your most recent purchase of a fancy tablet of $453.00 to a 653-px-long bar, and your last night's pub bill of $23.59 to a 34-px-long bar. In a sense, this is what data visualization is all about, mapping data elements to their visual metaphor in an efficient and accurate manner. Because this is an absolutely essential task in data visualization and animation (animation will be discussed in Chapter 6, Transition with Style, in detail), D3 provides rich and robust support on this topic, which is the focus of this chapter.
What are scales?
D3 provides various constructs called scales to help you perform this kind of mapping. A proper understanding of these constructs conceptually is crucial to become an effective visualization developer. This is because scales are used not only to perform the...