Margins and axes
Adding axes to the graph will give the reader a much better understanding of the scope of the graph and the relationship between the values in the data. D3.js has very powerful constructs built in for allowing us to create axes.
Axes in D3.js are based upon another concept known as scales. While scales are by themselves very useful (we will cover scales in more detail in Chapter 5, Using Data and Scales), for the remainder of this chapter, we will examine using them to create basic axes in our bar chart.
However, before we get to axes, we will first take a short but important diversion into the concept of margins, and that of adding a margin to our bar chart to make room for the axes.
Creating margins in the bar graph
Margins have ...
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.