Skip to main content
100%

Pie Chart II

✓ Published0🌍 Public
11Cr18Ni9
Last edited Jan 10, 2017
Created on Jan 5, 2017

A pie chart animates its slices outward on hover. The example uses D3 v3 with SVG and animation. Each slice’s path is drawn with `d3.svg.arc`, and hovering triggers a transition via `transition.attrTween`, interpolating the slice’s `outerRadius` to expand it. The dataset is a simple array of five values, with percentages displayed as rotated text labels. The code is adapted from Mike Bostock’s “Extending Arcs” block and was built with Blockbuilder.

AI-generated description

Built with blockbuilder.org

This example is animated with attrTween, if you hover pie partions you will get it.

At the begining, I got two mistakes:

  • Chained outerRadius attribute with arc generator, which make arc generator with a fixed outerRadius;

  • Constructing path works fine, but I forget every path tag doesn't bind the outerRadius data. After posting help on stackflow, I get the answer.

The code is enlighted by Mike Bostock's Extending Arcs.

mit Licensed

Similar vizzes