3D pie chart
A pie with a thickness, seen from above, a slice pulled out. Good for two to five shares, when one of them has to stand out.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
import 'nervure/3d';
const spec = {
type: 'pie3d',
data: [
{ name: 'Juice', value: 86 },
{ name: 'Tea', value: 10 },
{ name: 'Cheese', value: 59 },
{ name: 'Soup', value: 8 },
{ name: 'Dates', value: 42 },
],
explode: [0],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type pie3d takes:
/** A pie with a thickness, seen from above. */
interface Pie3DSpec extends Base3D {
type: 'pie3d';
data: Item[];
/** Slices pulled out of the pie: names or indexes. */
explode?: (string | number)[];
/** Thickness, as a share of the radius: 0.18 by default. */
depth?: number;
/** Names and shares outside the pie, with a line to their slice: true by default when there is room. */
labels?: boolean;
legend?: boolean | LegendOptions;
onItemClick?: (id: string) => void;
}
interface Base3D extends Base {
/** Where the eye stands, in degrees: `azimuth` turns around the vertical axis, `elevation` rises from the floor (0) to straight above (90). */
view?: { azimuth?: number; elevation?: number };
/** Drag the chart, or focus its turn button and use the arrow keys, to turn the view. Home on the button goes back to `view`. */
rotate?: boolean;
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More