9. Adding a Play Button
In this chapter, we’ll be taking things up a notch by adding a play button to our bar chart. We’ll start by making a generalized update function that we can use to tell our bar chart to update to any given input year. Then we’ll actually add a play button to our page. And finally, we’ll make the whole thing work.
Wrapping the Update Phase in a Function
Think of this chapter as kind of like a bonus chapter. You’ve already learned everything you know to be well on your way to creating awesome graphics in D3. In this chapter, we’re just going to make that bar chart we’ve been working on slightly more sophisticated by adding a play button.
What will that play button do, exactly? When the user clicks on it, the chart will first ...