O'Reilly logo

Visual Storytelling with D3: An Introduction to Data Visualization in JavaScript™ by Ritchie S. King

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required