Skip to Main Content
Data Visualization with D3 and AngularJS
book

Data Visualization with D3 and AngularJS

by Christoph Körner
April 2015
Intermediate to advanced content levelIntermediate to advanced
278 pages
5h 38m
English
Packt Publishing
Content preview from Data Visualization with D3 and AngularJS

Transitions in charts

In this section, we will apply the knowledge of the discussed sections on animations and transitions to the charts that we designed in the previous chapters.

To create a basic enter animation for a bar chart—like the one that we can see in the following figure—we need to first create a transition for the position of each bar on the y axis and the height of each bar:

Transitions in charts

The bar chart

We want to animate from the position of the 0 value to the y value of the data point. Let's write this down as follows:

svg.select('.data') .selectAll('rect').data(data) .attr('r', 2.5) .attr('x', function(d) { return xScale(d.x) - barWidth*0.5; }) .attr('width', ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

D3.js: Cutting-edge Data Visualization

D3.js: Cutting-edge Data Visualization

Ændrew H. Rininsland, Michael Heydt, Pablo Navarro Castillo
D3.js 4.x Data Visualization - Third Edition

D3.js 4.x Data Visualization - Third Edition

Aendrew Rininsland, Swizec Teller
Intermediate D3.js

Intermediate D3.js

Scott Murray

Publisher Resources

ISBN: 9781784398484Supplemental Content