- Expert Data Visualization
- Jos Dirksen
- 255字
- 2025-04-04 19:31:10
Basic Charts and Shapes
In the previous chapter, we created a simple bar chart using the SVG rect element. While this works for simple charts, using the standard SVG elements for more complex charts can be difficult. Luckily, D3 provides an extensive set of helper functions that we can use to easily create more complex visualizations, without having to manipulate basic SVG elements ourselves. In this chapter, we're going to create visualizations based on data from the US Census Bureau (http://www.census.gov). To be more precise, we're going to create the following data visualizations:
- How long have American firms been in business visualized with pies and donuts: The US census releases an overview that shows how long firms have been in business. This provides a nice data set to show how D3 allows you to create pie and donut charts.
- Real Median Household income in the US visualized with a line chart: In the US Census data, there is information present on how the average household income has changed during the last thirty years. This is information that can be very nicely visualized using a line chart.
- Population growth estimates using a stacked graph: The US Census Bureau provides information on how the population of the US is expected to change from 2014 to 2060. We'll use this data to show how this can be visualized using a stacked graph.
To make the visualizations more interesting, we'll also add interactivity and animations to them. Let's get started with the first visualization: the donut and pie charts.