6. Sizing Charts and Adding Axes

This chapter covers how to use scales and easily create axes in D3. Scales make it straightforward to translate values in a data set to pixels on a screen. Axis generators make it exceedingly simple to add axes to your charts and customize them. By the end of the chapter, you will have recreated our single-year bar chart example using D3 to its fullest potential.

Linear Scales

In this chapter, instead of starting with general lessons on using D3 and then applying those lessons to our example bar chart, we are going to work on our bar chart from the get-go. Take the most recent version, pop2010-data-joins.html, save it as pop2010-scales.html, in both your browser and your text editor.

In the chapter on SVG, we ...

Get Visual Storytelling with D3: An Introduction to Data Visualization in JavaScript™ 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.