Donut Chart 3D

A 3D pie with a hole - slices as wide as their share and as tall as their value.

Chrome
Safari
Firefox
Edge
Other

The pie of this registry, with a hole: a slice is as wide as its share of the whole and as tall as its value, relative to the largest, so the depth carries the value twice over - the angle tells the share, the height compares the slices where the tilt bends their angles. A pie whose depth is only thickness has no place here (ADR-0015). The slices run in the order of the data, clockwise seen from above, the first from the back; each takes the color its id keys in the chart config, as the slices of the shadcn/ui pie do, unless series names another field.

Installation

npx shadcn@latest add niekes/chart3dcn/donut-chart-3d#v1.2.0

Update

Press Update: every slice glides to its new share and height over the animationDuration of its container.

Enter and leave

New data may also bring and drop whole slices - a slice follows the name of its entry, in the id field, within its series. An added browser widens out of its neighbours and rises as it fades in; a removed one narrows back into them and sinks as it fades out, the mirror of its entering, where it stood in the ring (see Enter in the glossary). A value that drops to 0 leaves the same way, and one that rises from 0 comes. A slice that changes its place in the order swaps with the ones it passes halfway through the glide: a ring has no room to let it by.

Renderers

The same chart on every renderer, side by side. The marks are data the chart hands to the container, and "svg" and "canvas" draw them all - where the browser has no canvas, as SVG.

SVG
Canvas

Many marks

A thousand slices - the most populous places of the world, the capitals in a color of their own - and the chart stays interactive. The scene is one list of marks, so the demo starts on "canvas", the renderer for many marks, and the select shows the same scene on SVG.

Capital
City

API Reference

Prop

Type

Edit on GitHub

On this page