Skip to main content
100%

Pie Chart Rotation on Click

✓ Published0🌍 Public
FFrissAnalytics
Last edited Sep 18, 2018
Created on Sep 18, 2018

This interactive pie chart displays population data by age group, with each wedge rotating to the bottom when clicked. Built with D3 v4, the visualization uses `d3.pie` and `d3.arc` to generate SVG paths, while a `transition` on the containing `<g>` element rotates the entire chart so the selected wedge aligns with the bottom. Label text rotates in the opposite direction to stay upright, and clicks are handled via the `.on("click")` method. The data is hardcoded in the script, and the chart is styled with ordinal color scales for the seven age categories.

AI-generated description

This pie chart, based on Mike Bostock's example, rotates so that any clicked wedge well spin to the bottom. The text rotates in the opposite direction so that it remains upright.

Part of this answer on Stack Overflow

forked from <a href='http://bl.ocks.org/Andrew-Reid/'>Andrew-Reid</a>'s block: <a href='http://bl.ocks.org/Andrew-Reid/a73f9af9ccd9ef901a0c33c624096049'>Pie Chart Rotation on Click</a>

mit Licensed

Similar vizzes