Baking a fresh 'n' delicious pie chart

The preceding bar chart reveals that Ed Miliband received the most donations during this period. Let's find out who's making him so popular.

We are going to use the pie chart layout to cut the donations to The Rt Hon Edward Miliband MP into slices, showing how many donations he got from each donor. After filtering the dataset for donations going to Miliband, we have to categorize the entries by givers, and finally we feed them into the pie chart layout to generate a pie chart.

We can use the histogram layout to put data into bins depending on the DonorName property. Let's add a function to helpers.js:

export function binPerName (data, name) { let nameIds = nameId(data, name); let histogram = d3.layout.histogram() ...

Get D3.js: Cutting-edge Data Visualization now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.