-
Book Overview & Buying
-
Table Of Contents
Learn D3.js - Second Edition
By :
In this chapter, you will learn how to create pie charts, stacked bar charts, and stacked area charts. These visualizations require complex data structures, which can be built with the help of layout generators.
A layout generator doesn’t generate any shapes, but instead transforms a dataset, altering its structure and adding properties so that it can be more easily assembled as a visual structure, or used by a shape generator that expects a specific format. The two layout generators in the d3-shape module are used to build data structures for pies and stacks.
Pies are built from arcs, rendered as SVG paths using the arc shape generator. A pie chart uses arcs to create slices that fit perfectly in a circle. To draw an arc, you must compute its radius and start and end angles. A pie layout generator easily computes these values from a data array.
Stacked charts combine data points from multiple series to show their cumulative effect. To create...