@cdx-ui/components 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/coverage.svg +1 -1
- package/docs/components/bar-chart/content.md +703 -0
- package/docs/components/content.md +9 -1
- package/docs/components/line-chart/content.md +567 -0
- package/docs/components/pie-chart/content.md +493 -0
- package/docs/components/progress-segmented/content.md +1 -1
- package/docs/components/stepper/content.md +599 -0
- package/docs/components/system-alert/content.md +533 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +2 -1
- package/docs/llms.txt +9 -0
- package/docs/patterns/content.md +1 -0
- package/docs/patterns/dashboard/content.md +423 -19
- package/docs/patterns/insights/content.md +590 -0
- package/docs/resources/release-notes/0.3.5/content.md +7 -0
- package/docs/resources/release-notes/content.md +1 -0
- package/lib/commonjs/components/BarChart/geometry.js +1130 -0
- package/lib/commonjs/components/BarChart/geometry.js.map +1 -0
- package/lib/commonjs/components/BarChart/index.js +942 -0
- package/lib/commonjs/components/BarChart/index.js.map +1 -0
- package/lib/commonjs/components/BarChart/styles.js +26 -0
- package/lib/commonjs/components/BarChart/styles.js.map +1 -0
- package/lib/commonjs/components/Button/index.js +2 -2
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/LineChart/geometry.js +698 -0
- package/lib/commonjs/components/LineChart/geometry.js.map +1 -0
- package/lib/commonjs/components/LineChart/index.js +747 -0
- package/lib/commonjs/components/LineChart/index.js.map +1 -0
- package/lib/commonjs/components/LineChart/styles.js +25 -0
- package/lib/commonjs/components/LineChart/styles.js.map +1 -0
- package/lib/commonjs/components/PieChart/geometry.js +216 -0
- package/lib/commonjs/components/PieChart/geometry.js.map +1 -0
- package/lib/commonjs/components/PieChart/index.js +476 -0
- package/lib/commonjs/components/PieChart/index.js.map +1 -0
- package/lib/commonjs/components/PieChart/styles.js +88 -0
- package/lib/commonjs/components/PieChart/styles.js.map +1 -0
- package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js +9 -31
- package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
- package/lib/commonjs/components/ProgressCircle/ProgressRing.js +52 -0
- package/lib/commonjs/components/ProgressCircle/ProgressRing.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +8 -7
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/commonjs/components/Stepper/index.js +369 -0
- package/lib/commonjs/components/Stepper/index.js.map +1 -0
- package/lib/commonjs/components/Stepper/styles.js +211 -0
- package/lib/commonjs/components/Stepper/styles.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.js +22 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js +52 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperRingColors.js +31 -0
- package/lib/commonjs/components/Stepper/useStepperRingColors.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/animation.js +218 -0
- package/lib/commonjs/components/SystemAlert/animation.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/index.js +525 -0
- package/lib/commonjs/components/SystemAlert/index.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/styles.js +178 -0
- package/lib/commonjs/components/SystemAlert/styles.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js +53 -0
- package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
- package/lib/commonjs/components/Tabs/index.js +4 -0
- package/lib/commonjs/components/Tabs/index.js.map +1 -1
- package/lib/commonjs/components/Tabs/styles.js +1 -1
- package/lib/commonjs/components/Tabs/styles.js.map +1 -1
- package/lib/commonjs/components/chart/ChartInspector.js +610 -0
- package/lib/commonjs/components/chart/ChartInspector.js.map +1 -0
- package/lib/commonjs/components/chart/format.js +93 -0
- package/lib/commonjs/components/chart/format.js.map +1 -0
- package/lib/commonjs/components/chart/index.js +2 -0
- package/lib/commonjs/components/chart/index.js.map +1 -0
- package/lib/commonjs/components/chart/motion.js +97 -0
- package/lib/commonjs/components/chart/motion.js.map +1 -0
- package/lib/commonjs/components/chart/palette.js +178 -0
- package/lib/commonjs/components/chart/palette.js.map +1 -0
- package/lib/commonjs/components/chart/size.js +34 -0
- package/lib/commonjs/components/chart/size.js.map +1 -0
- package/lib/commonjs/components/chart/ticks.js +59 -0
- package/lib/commonjs/components/chart/ticks.js.map +1 -0
- package/lib/commonjs/components/chart/types.js +6 -0
- package/lib/commonjs/components/chart/types.js.map +1 -0
- package/lib/commonjs/components/chart/useChartHostWidth.js +27 -0
- package/lib/commonjs/components/chart/useChartHostWidth.js.map +1 -0
- package/lib/commonjs/components/index.js +60 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/figma/SystemAlert.Button.figma.js +28 -0
- package/lib/commonjs/figma/SystemAlert.Button.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.Close.figma.js +22 -0
- package/lib/commonjs/figma/SystemAlert.Close.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.Description.figma.js +20 -0
- package/lib/commonjs/figma/SystemAlert.Description.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.IconButton.figma.js +31 -0
- package/lib/commonjs/figma/SystemAlert.IconButton.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.figma.js +48 -0
- package/lib/commonjs/figma/SystemAlert.figma.js.map +1 -0
- package/lib/module/components/BarChart/geometry.js +1110 -0
- package/lib/module/components/BarChart/geometry.js.map +1 -0
- package/lib/module/components/BarChart/index.js +936 -0
- package/lib/module/components/BarChart/index.js.map +1 -0
- package/lib/module/components/BarChart/styles.js +22 -0
- package/lib/module/components/BarChart/styles.js.map +1 -0
- package/lib/module/components/Button/index.js +2 -2
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/LineChart/geometry.js +685 -0
- package/lib/module/components/LineChart/geometry.js.map +1 -0
- package/lib/module/components/LineChart/index.js +741 -0
- package/lib/module/components/LineChart/index.js.map +1 -0
- package/lib/module/components/LineChart/styles.js +21 -0
- package/lib/module/components/LineChart/styles.js.map +1 -0
- package/lib/module/components/PieChart/geometry.js +209 -0
- package/lib/module/components/PieChart/geometry.js.map +1 -0
- package/lib/module/components/PieChart/index.js +471 -0
- package/lib/module/components/PieChart/index.js.map +1 -0
- package/lib/module/components/PieChart/styles.js +84 -0
- package/lib/module/components/PieChart/styles.js.map +1 -0
- package/lib/module/components/ProgressCircle/ProgressCircleRing.js +10 -32
- package/lib/module/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
- package/lib/module/components/ProgressCircle/ProgressRing.js +48 -0
- package/lib/module/components/ProgressCircle/ProgressRing.js.map +1 -0
- package/lib/module/components/ScrollShadow/useScrollShadow.js +8 -7
- package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/module/components/Stepper/index.js +360 -0
- package/lib/module/components/Stepper/index.js.map +1 -0
- package/lib/module/components/Stepper/styles.js +206 -0
- package/lib/module/components/Stepper/styles.js.map +1 -0
- package/lib/module/components/Stepper/useStepperLabelFit.js +18 -0
- package/lib/module/components/Stepper/useStepperLabelFit.js.map +1 -0
- package/lib/module/components/Stepper/useStepperLabelFit.web.js +48 -0
- package/lib/module/components/Stepper/useStepperLabelFit.web.js.map +1 -0
- package/lib/module/components/Stepper/useStepperRingColors.js +28 -0
- package/lib/module/components/Stepper/useStepperRingColors.js.map +1 -0
- package/lib/module/components/SystemAlert/animation.js +213 -0
- package/lib/module/components/SystemAlert/animation.js.map +1 -0
- package/lib/module/components/SystemAlert/index.js +515 -0
- package/lib/module/components/SystemAlert/index.js.map +1 -0
- package/lib/module/components/SystemAlert/styles.js +174 -0
- package/lib/module/components/SystemAlert/styles.js.map +1 -0
- package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js +49 -0
- package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
- package/lib/module/components/Tabs/index.js +4 -0
- package/lib/module/components/Tabs/index.js.map +1 -1
- package/lib/module/components/Tabs/styles.js +1 -1
- package/lib/module/components/Tabs/styles.js.map +1 -1
- package/lib/module/components/chart/ChartInspector.js +600 -0
- package/lib/module/components/chart/ChartInspector.js.map +1 -0
- package/lib/module/components/chart/format.js +84 -0
- package/lib/module/components/chart/format.js.map +1 -0
- package/lib/module/components/chart/index.js +2 -0
- package/lib/module/components/chart/index.js.map +1 -0
- package/lib/module/components/chart/motion.js +89 -0
- package/lib/module/components/chart/motion.js.map +1 -0
- package/lib/module/components/chart/palette.js +168 -0
- package/lib/module/components/chart/palette.js.map +1 -0
- package/lib/module/components/chart/size.js +29 -0
- package/lib/module/components/chart/size.js.map +1 -0
- package/lib/module/components/chart/ticks.js +55 -0
- package/lib/module/components/chart/ticks.js.map +1 -0
- package/lib/module/components/chart/types.js +4 -0
- package/lib/module/components/chart/types.js.map +1 -0
- package/lib/module/components/chart/useChartHostWidth.js +23 -0
- package/lib/module/components/chart/useChartHostWidth.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/figma/SystemAlert.Button.figma.js +22 -0
- package/lib/module/figma/SystemAlert.Button.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.Close.figma.js +18 -0
- package/lib/module/figma/SystemAlert.Close.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.Description.figma.js +14 -0
- package/lib/module/figma/SystemAlert.Description.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.IconButton.figma.js +25 -0
- package/lib/module/figma/SystemAlert.IconButton.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.figma.js +42 -0
- package/lib/module/figma/SystemAlert.figma.js.map +1 -0
- package/lib/typescript/components/BarChart/geometry.d.ts +236 -0
- package/lib/typescript/components/BarChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/BarChart/index.d.ts +193 -0
- package/lib/typescript/components/BarChart/index.d.ts.map +1 -0
- package/lib/typescript/components/BarChart/styles.d.ts +32 -0
- package/lib/typescript/components/BarChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/geometry.d.ts +248 -0
- package/lib/typescript/components/LineChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/index.d.ts +105 -0
- package/lib/typescript/components/LineChart/index.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/styles.d.ts +12 -0
- package/lib/typescript/components/LineChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/geometry.d.ts +43 -0
- package/lib/typescript/components/PieChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/index.d.ts +147 -0
- package/lib/typescript/components/PieChart/index.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/styles.d.ts +27 -0
- package/lib/typescript/components/PieChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/ProgressCircle/ProgressCircleRing.d.ts.map +1 -1
- package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts +17 -0
- package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
- package/lib/typescript/components/Stepper/index.d.ts +68 -0
- package/lib/typescript/components/Stepper/index.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/styles.d.ts +46 -0
- package/lib/typescript/components/Stepper/styles.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts +15 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts +10 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperRingColors.d.ts +6 -0
- package/lib/typescript/components/Stepper/useStepperRingColors.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/animation.d.ts +56 -0
- package/lib/typescript/components/SystemAlert/animation.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/index.d.ts +110 -0
- package/lib/typescript/components/SystemAlert/index.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/styles.d.ts +38 -0
- package/lib/typescript/components/SystemAlert/styles.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts +14 -0
- package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts.map +1 -0
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
- package/lib/typescript/components/chart/ChartInspector.d.ts +101 -0
- package/lib/typescript/components/chart/ChartInspector.d.ts.map +1 -0
- package/lib/typescript/components/chart/format.d.ts +16 -0
- package/lib/typescript/components/chart/format.d.ts.map +1 -0
- package/lib/typescript/components/chart/index.d.ts +3 -0
- package/lib/typescript/components/chart/index.d.ts.map +1 -0
- package/lib/typescript/components/chart/motion.d.ts +27 -0
- package/lib/typescript/components/chart/motion.d.ts.map +1 -0
- package/lib/typescript/components/chart/palette.d.ts +44 -0
- package/lib/typescript/components/chart/palette.d.ts.map +1 -0
- package/lib/typescript/components/chart/size.d.ts +25 -0
- package/lib/typescript/components/chart/size.d.ts.map +1 -0
- package/lib/typescript/components/chart/ticks.d.ts +3 -0
- package/lib/typescript/components/chart/ticks.d.ts.map +1 -0
- package/lib/typescript/components/chart/types.d.ts +163 -0
- package/lib/typescript/components/chart/types.d.ts.map +1 -0
- package/lib/typescript/components/chart/useChartHostWidth.d.ts +9 -0
- package/lib/typescript/components/chart/useChartHostWidth.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +5 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/figma/SystemAlert.Button.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.Button.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.Close.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.Close.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.Description.figma.d.ts +8 -0
- package/lib/typescript/figma/SystemAlert.Description.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.figma.d.ts +8 -0
- package/lib/typescript/figma/SystemAlert.figma.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/components/BarChart/geometry.ts +1469 -0
- package/src/components/BarChart/index.tsx +1424 -0
- package/src/components/BarChart/styles.ts +31 -0
- package/src/components/Button/index.tsx +1 -1
- package/src/components/LineChart/geometry.ts +957 -0
- package/src/components/LineChart/index.tsx +1109 -0
- package/src/components/LineChart/styles.ts +26 -0
- package/src/components/PieChart/geometry.ts +295 -0
- package/src/components/PieChart/index.tsx +715 -0
- package/src/components/PieChart/styles.ts +101 -0
- package/src/components/ProgressCircle/ProgressCircleRing.tsx +10 -39
- package/src/components/ProgressCircle/ProgressRing.tsx +60 -0
- package/src/components/ScrollShadow/useScrollShadow.ts +12 -11
- package/src/components/Stepper/index.tsx +452 -0
- package/src/components/Stepper/styles.ts +234 -0
- package/src/components/Stepper/useStepperLabelFit.ts +21 -0
- package/src/components/Stepper/useStepperLabelFit.web.ts +53 -0
- package/src/components/Stepper/useStepperRingColors.ts +29 -0
- package/src/components/SystemAlert/animation.ts +252 -0
- package/src/components/SystemAlert/index.tsx +684 -0
- package/src/components/SystemAlert/styles.ts +212 -0
- package/src/components/SystemAlert/useSystemAlertStatusBarStyle.ts +57 -0
- package/src/components/Tabs/index.tsx +4 -0
- package/src/components/Tabs/styles.ts +1 -1
- package/src/components/chart/ChartInspector.tsx +726 -0
- package/src/components/chart/format.ts +95 -0
- package/src/components/chart/index.ts +24 -0
- package/src/components/chart/motion.ts +98 -0
- package/src/components/chart/palette.tsx +247 -0
- package/src/components/chart/size.ts +21 -0
- package/src/components/chart/ticks.ts +53 -0
- package/src/components/chart/types.ts +183 -0
- package/src/components/chart/useChartHostWidth.ts +26 -0
- package/src/components/index.ts +5 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
# Pie Chart (https://design.candescent.com/docs/components/pie-chart)
|
|
2
|
+
|
|
3
|
+
Resources: [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/charts-piechart--default)
|
|
4
|
+
|
|
5
|
+
`PieChart` takes MUI X–shaped `series`: one series with a `data` array of `{ id, value, label?, color? }` slices. Give every slice a stable `id`; keys, selection, and animation follow it. The [Insights Overview](https://design.candescent.com/docs/patterns/dashboard/content.md#insights-overview) pattern uses a small donut as a progress ring and a donut with a list legend.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { PieChart } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
A filled pie with a wrapping chip legend under the chart (`legendLayout="wrap"`). Each chip is the name and share. Hover a slice, or press and hold it on touch screens, for the tooltip.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { PieChart } from '@cdx-ui/components';
|
|
17
|
+
import { SPENDING } from './_data';
|
|
18
|
+
|
|
19
|
+
export default function PieChartBasicDemo() {
|
|
20
|
+
return <PieChart series={[{ id: 'spending', data: SPENDING }]} />;
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Sizes
|
|
25
|
+
|
|
26
|
+
`size` picks a preset plot box: `sm`, `md`, `lg` (the default), or `xl`. `width` and `height` override one side.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { useState } from 'react';
|
|
30
|
+
import { Box, PieChart, Slider, VStack } from '@cdx-ui/components';
|
|
31
|
+
import { VISITS } from './_data';
|
|
32
|
+
|
|
33
|
+
const SIZES = ['sm', 'md', 'lg', 'xl'] as const;
|
|
34
|
+
|
|
35
|
+
export default function PieChartSizesDemo() {
|
|
36
|
+
const [index, setIndex] = useState(2);
|
|
37
|
+
const size = SIZES[index] ?? 'lg';
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<VStack space="2xl" className="w-full items-center">
|
|
41
|
+
<Box className="w-full max-w-xs">
|
|
42
|
+
<Slider
|
|
43
|
+
value={index}
|
|
44
|
+
onChange={setIndex}
|
|
45
|
+
min={0}
|
|
46
|
+
max={SIZES.length - 1}
|
|
47
|
+
step={1}
|
|
48
|
+
accessibilityLabel="Chart size"
|
|
49
|
+
>
|
|
50
|
+
<Slider.Rail>
|
|
51
|
+
<Slider.Track />
|
|
52
|
+
</Slider.Rail>
|
|
53
|
+
<Slider.Thumb>
|
|
54
|
+
<Slider.Popup>{size}</Slider.Popup>
|
|
55
|
+
</Slider.Thumb>
|
|
56
|
+
<Slider.MarkerGroup>
|
|
57
|
+
<Slider.Marker />
|
|
58
|
+
</Slider.MarkerGroup>
|
|
59
|
+
</Slider>
|
|
60
|
+
</Box>
|
|
61
|
+
<PieChart
|
|
62
|
+
key={size}
|
|
63
|
+
series={[
|
|
64
|
+
{ id: 'visits', data: VISITS, innerRadius: '60%', paddingAngle: 2, cornerRadius: 4 },
|
|
65
|
+
]}
|
|
66
|
+
size={size}
|
|
67
|
+
/>
|
|
68
|
+
</VStack>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Donut
|
|
74
|
+
|
|
75
|
+
A series `innerRadius` above `0` opens a hole for `centerLabel`. `paddingAngle` leaves a gap between slices in degrees; `cornerRadius` rounds the cut ends.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { Box, PieChart, Text } from '@cdx-ui/components';
|
|
79
|
+
import { SPENDING } from './_data';
|
|
80
|
+
|
|
81
|
+
export default function PieChartDonutDemo() {
|
|
82
|
+
return (
|
|
83
|
+
<PieChart
|
|
84
|
+
series={[
|
|
85
|
+
{ id: 'spending', data: SPENDING, innerRadius: '68%', paddingAngle: 2, cornerRadius: 6 },
|
|
86
|
+
]}
|
|
87
|
+
centerLabel={
|
|
88
|
+
<Box className="items-center">
|
|
89
|
+
<Text size="xs" color="secondary">
|
|
90
|
+
Total
|
|
91
|
+
</Text>
|
|
92
|
+
<Text weight="medium">$3,872.64</Text>
|
|
93
|
+
</Box>
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Slice colors
|
|
101
|
+
|
|
102
|
+
A slice's `color` takes a chart token (`simple-*`, `categorical-*`) or a severity token (`danger`, `warning`, `success`, `info`). Give severity tokens only to the slices the reader should act on, and keep the rest in the brand family. A slice without `color` takes the next `categorical-1`…`6` slot.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { Box, PieChart, Text } from '@cdx-ui/components';
|
|
106
|
+
|
|
107
|
+
export default function PieChartColorsDemo() {
|
|
108
|
+
return (
|
|
109
|
+
<PieChart
|
|
110
|
+
series={[
|
|
111
|
+
{
|
|
112
|
+
id: 'charges',
|
|
113
|
+
innerRadius: '68%',
|
|
114
|
+
paddingAngle: 2,
|
|
115
|
+
cornerRadius: 6,
|
|
116
|
+
data: [
|
|
117
|
+
{ id: 'purchases', label: 'Purchases', value: 1240, color: 'simple-primary' },
|
|
118
|
+
{ id: 'interest', label: 'Interest', value: 310, color: 'warning' },
|
|
119
|
+
{ id: 'late-fees', label: 'Late fees', value: 140, color: 'danger' },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
]}
|
|
123
|
+
centerLabel={
|
|
124
|
+
<Box className="items-center">
|
|
125
|
+
<Text size="xs" color="secondary">
|
|
126
|
+
Late fees
|
|
127
|
+
</Text>
|
|
128
|
+
<Text weight="medium">$140</Text>
|
|
129
|
+
</Box>
|
|
130
|
+
}
|
|
131
|
+
accessibilityLabel="Card charges this statement. Late fees were $140."
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Legend list
|
|
138
|
+
|
|
139
|
+
`legendLayout="list"` is the spending-breakdown pattern: name on the left, amount and share on the right. The series `valueFormatter` paints the amount column. It is a `(value, context) => string`, not a currency prop.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { Box, PieChart, Text } from '@cdx-ui/components';
|
|
143
|
+
import { formatUsdValue, SPENDING } from './_data';
|
|
144
|
+
|
|
145
|
+
export default function PieChartLegendListDemo() {
|
|
146
|
+
return (
|
|
147
|
+
<PieChart
|
|
148
|
+
series={[
|
|
149
|
+
{
|
|
150
|
+
id: 'spending',
|
|
151
|
+
data: SPENDING,
|
|
152
|
+
innerRadius: '68%',
|
|
153
|
+
paddingAngle: 2,
|
|
154
|
+
cornerRadius: 6,
|
|
155
|
+
valueFormatter: formatUsdValue,
|
|
156
|
+
},
|
|
157
|
+
]}
|
|
158
|
+
legendLayout="list"
|
|
159
|
+
centerLabel={
|
|
160
|
+
<Box className="items-center">
|
|
161
|
+
<Text size="xs" color="secondary">
|
|
162
|
+
Total
|
|
163
|
+
</Text>
|
|
164
|
+
<Text weight="medium">$3,872.64</Text>
|
|
165
|
+
</Box>
|
|
166
|
+
}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Legend placement
|
|
173
|
+
|
|
174
|
+
`legendPlacement` matches Drawer (`top`, `bottom`, `left`, `right`). Left and right are swatch plus name only; `legendLayout` is ignored. Switch placements to compare them.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import { useState } from 'react';
|
|
178
|
+
import {
|
|
179
|
+
Box,
|
|
180
|
+
PieChart,
|
|
181
|
+
Text,
|
|
182
|
+
ToggleButton,
|
|
183
|
+
VStack,
|
|
184
|
+
type PieChartLegendPlacement,
|
|
185
|
+
} from '@cdx-ui/components';
|
|
186
|
+
import { SPENDING } from './_data';
|
|
187
|
+
|
|
188
|
+
const PLACEMENTS: readonly PieChartLegendPlacement[] = ['top', 'bottom', 'left', 'right'];
|
|
189
|
+
|
|
190
|
+
const LABELS: Record<PieChartLegendPlacement, string> = {
|
|
191
|
+
top: 'Top',
|
|
192
|
+
bottom: 'Bottom',
|
|
193
|
+
left: 'Left',
|
|
194
|
+
right: 'Right',
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export default function PieChartLegendPlacementDemo() {
|
|
198
|
+
const [placement, setPlacement] = useState<PieChartLegendPlacement>('right');
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<VStack space="3xl" className="w-full items-center">
|
|
202
|
+
<ToggleButton.Group
|
|
203
|
+
type="single"
|
|
204
|
+
value={placement}
|
|
205
|
+
onValueChange={(value) => {
|
|
206
|
+
const next = PLACEMENTS.find((item) => item === value);
|
|
207
|
+
if (next) {
|
|
208
|
+
setPlacement(next);
|
|
209
|
+
}
|
|
210
|
+
}}
|
|
211
|
+
aria-label="Legend placement"
|
|
212
|
+
className="self-center"
|
|
213
|
+
>
|
|
214
|
+
{PLACEMENTS.map((item) => (
|
|
215
|
+
<ToggleButton key={item} value={item}>
|
|
216
|
+
<ToggleButton.Label>{LABELS[item]}</ToggleButton.Label>
|
|
217
|
+
</ToggleButton>
|
|
218
|
+
))}
|
|
219
|
+
</ToggleButton.Group>
|
|
220
|
+
<PieChart
|
|
221
|
+
series={[
|
|
222
|
+
{ id: 'spending', data: SPENDING, innerRadius: '68%', paddingAngle: 2, cornerRadius: 6 },
|
|
223
|
+
]}
|
|
224
|
+
size="md"
|
|
225
|
+
legendPlacement={placement}
|
|
226
|
+
centerLabel={
|
|
227
|
+
<Box className="items-center">
|
|
228
|
+
<Text size="xs" color="secondary">
|
|
229
|
+
Total
|
|
230
|
+
</Text>
|
|
231
|
+
<Text weight="medium">$3,872.64</Text>
|
|
232
|
+
</Box>
|
|
233
|
+
}
|
|
234
|
+
/>
|
|
235
|
+
</VStack>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Format value
|
|
241
|
+
|
|
242
|
+
`valueFormatter` formats the amount in the legend, tooltip, and screen reader text; `context.location` says which (`label`, `tooltip`, `a11y`). `shareFormatter` formats the share column the same way.
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
import { PieChart } from '@cdx-ui/components';
|
|
246
|
+
import { VISITS } from './_data';
|
|
247
|
+
|
|
248
|
+
export default function PieChartFormatValueDemo() {
|
|
249
|
+
return (
|
|
250
|
+
<PieChart
|
|
251
|
+
series={[
|
|
252
|
+
{
|
|
253
|
+
id: 'visits',
|
|
254
|
+
label: 'Visits',
|
|
255
|
+
data: VISITS,
|
|
256
|
+
innerRadius: '68%',
|
|
257
|
+
valueFormatter: (value) => (value === null ? '' : `${String(value)} visits`),
|
|
258
|
+
shareFormatter: (share) => `${(share * 100).toFixed(1)}%`,
|
|
259
|
+
},
|
|
260
|
+
]}
|
|
261
|
+
legendLayout="list"
|
|
262
|
+
centerLabel="246"
|
|
263
|
+
/>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Locale
|
|
269
|
+
|
|
270
|
+
`locale` sets the default number and percent format. `localeText` replaces generated strings such as the screen reader summary.
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
import { PieChart } from '@cdx-ui/components';
|
|
274
|
+
import { SPENDING } from './_data';
|
|
275
|
+
|
|
276
|
+
export default function PieChartLocaleDemo() {
|
|
277
|
+
return (
|
|
278
|
+
<PieChart
|
|
279
|
+
series={[{ id: 'ausgaben', data: SPENDING, innerRadius: '68%' }]}
|
|
280
|
+
legendLayout="list"
|
|
281
|
+
locale="de-DE"
|
|
282
|
+
localeText={{
|
|
283
|
+
pieChartSummary: (slices) =>
|
|
284
|
+
`Kreisdiagramm. ${slices.map((slice) => `${slice.label} ${slice.formattedValue}`).join(', ')}.`,
|
|
285
|
+
}}
|
|
286
|
+
/>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Selectable
|
|
292
|
+
|
|
293
|
+
Pass `selectedItem` and `onSelectedItemChange` (or `defaultSelectedItem`) to dim unselected slices. The item is `{ seriesId, dataIndex }`; pressing the selected slice again reports `null`.
|
|
294
|
+
|
|
295
|
+
Hovering or focusing a slice or legend row previews it without changing the selection; click, tap, or Enter commits. Pass `centerLabel` as a function to follow that preview: it receives the active slice (`id`, `dataIndex`, `label`, `value`, `percentage`), falling back to the selected one, or `null` when neither exists.
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
import { useState } from 'react';
|
|
299
|
+
import { Box, PieChart, Text, VStack, type ChartSelectedItem } from '@cdx-ui/components';
|
|
300
|
+
import { formatUsd, SPENDING } from './_data';
|
|
301
|
+
|
|
302
|
+
export default function PieChartSelectableDemo() {
|
|
303
|
+
const [selectedItem, setSelectedItem] = useState<ChartSelectedItem>({
|
|
304
|
+
seriesId: 'spending',
|
|
305
|
+
dataIndex: 0,
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<VStack space="md" className="w-full">
|
|
310
|
+
<Text size="sm" color="secondary">
|
|
311
|
+
{selectedItem ? (SPENDING[selectedItem.dataIndex]?.label ?? 'None') : 'None'}
|
|
312
|
+
</Text>
|
|
313
|
+
<PieChart
|
|
314
|
+
series={[
|
|
315
|
+
{ id: 'spending', data: SPENDING, innerRadius: '68%', paddingAngle: 2, cornerRadius: 6 },
|
|
316
|
+
]}
|
|
317
|
+
selectedItem={selectedItem}
|
|
318
|
+
onSelectedItemChange={setSelectedItem}
|
|
319
|
+
centerLabel={(slice) =>
|
|
320
|
+
slice ? (
|
|
321
|
+
<Box className="items-center">
|
|
322
|
+
<Text size="xs" color="secondary">
|
|
323
|
+
{slice.label}
|
|
324
|
+
</Text>
|
|
325
|
+
<Text weight="medium">{formatUsd(slice.value)}</Text>
|
|
326
|
+
</Box>
|
|
327
|
+
) : null
|
|
328
|
+
}
|
|
329
|
+
/>
|
|
330
|
+
</VStack>
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Data change
|
|
336
|
+
|
|
337
|
+
Slices tween to their new shares when `data` changes. Keep each slice's `id` stable: animation follows it, so a reordered slice moves to its new position instead of remounting. Pass `animation="disable-all"` to draw the final state; Reduce Motion and `GlobalAnimationSettingsProvider` `disable-all` also turn it off.
|
|
338
|
+
|
|
339
|
+
```tsx
|
|
340
|
+
import { useState } from 'react';
|
|
341
|
+
import { Button, HStack, PieChart, VStack } from '@cdx-ui/components';
|
|
342
|
+
import { SPENDING } from './_data';
|
|
343
|
+
|
|
344
|
+
export default function PieChartDataChangeDemo() {
|
|
345
|
+
const [step, setStep] = useState(0);
|
|
346
|
+
const [reversed, setReversed] = useState(false);
|
|
347
|
+
const shifted = SPENDING.map((slice, index) => ({
|
|
348
|
+
...slice,
|
|
349
|
+
value: SPENDING[(index + step) % SPENDING.length]?.value ?? slice.value,
|
|
350
|
+
}));
|
|
351
|
+
const data = reversed ? [...shifted].reverse() : shifted;
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<VStack space="lg" className="w-full items-center">
|
|
355
|
+
<PieChart
|
|
356
|
+
series={[{ id: 'spending', data, innerRadius: '68%', paddingAngle: 2, cornerRadius: 6 }]}
|
|
357
|
+
/>
|
|
358
|
+
<HStack space="sm" className="flex-wrap justify-center">
|
|
359
|
+
<Button
|
|
360
|
+
variant="outline"
|
|
361
|
+
onPress={() => {
|
|
362
|
+
setStep((prev) => prev + 1);
|
|
363
|
+
}}
|
|
364
|
+
>
|
|
365
|
+
<Button.Label>Shift data</Button.Label>
|
|
366
|
+
</Button>
|
|
367
|
+
<Button
|
|
368
|
+
variant="outline"
|
|
369
|
+
onPress={() => {
|
|
370
|
+
setReversed((prev) => !prev);
|
|
371
|
+
}}
|
|
372
|
+
>
|
|
373
|
+
<Button.Label>Reverse order</Button.Label>
|
|
374
|
+
</Button>
|
|
375
|
+
</HStack>
|
|
376
|
+
</VStack>
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## API
|
|
382
|
+
|
|
383
|
+
### PieChart
|
|
384
|
+
|
|
385
|
+
Draws the first series as a pie or donut, with an optional legend, tooltip, and selection.
|
|
386
|
+
|
|
387
|
+
| Prop | Type | Default | Description |
|
|
388
|
+
| --- | --- | --- | --- |
|
|
389
|
+
| `className?` | `string` | — | Additional Uniwind/Tailwind classes, merged after the root's own styles. |
|
|
390
|
+
| `accessibilityLabel?` | `string` | — | Names the plot image. Defaults to `localeText.pieChartSummary` over labels and shares. Not applied when `hideLegend` on a selectable chart makes each slice a button. |
|
|
391
|
+
| `series` | `readonly PieChartSeries[]` | — | Pie series. Only the first renders; more than one logs a development warning. The pie diameter is the shorter side of the `size` / `width` / `height` box. |
|
|
392
|
+
| `hideLegend?` | `boolean` | `false` | Hides the category legend. With the legend hidden, a selectable chart makes each slice a button; otherwise the plot is one image with a generated summary. |
|
|
393
|
+
| `legendLayout?` | `'wrap' \| 'list'` | `'wrap'` | How legend items are laid out when `legendPlacement` is `top` or `bottom`. `wrap` is centered chips (`Housing 46%`). `list` is full-width rows: name on the left, formatted value and share on the right, with a hairline between rows. Ignored when the legend is on the left or right. |
|
|
394
|
+
| `legendPlacement?` | `'top' \| 'bottom' \| 'left' \| 'right'` | `'bottom'` | Where the legend sits relative to the plot, matching Drawer `placement`. `top` / `bottom` use `legendLayout`. `left` / `right` are swatch + name only (no amount, no percent). |
|
|
395
|
+
| `tooltip?` | `ChartTooltipProps` | `{ trigger: 'item' }` | `item` shows the slice under the pointer or keyboard focus (on touch, the slice under the finger until it lifts). `axis` behaves like `item` because a pie has no axis. `none` hides the tooltip. |
|
|
396
|
+
| `centerLabel?` | `ReactNode \| ((slice: PieChartActiveSlice \| null) => ReactNode)` | — | Content in the donut hole. A string becomes styled `Text`. Pass a `View` for stacked copy such as “Total” over an amount. Pass a function to follow the active slice: it receives the hovered or focused slice, else the selected one, else `null` — return the total for `null`. |
|
|
397
|
+
| `selectedItem?` | `ChartSelectedItem` | — | Controlled selected slice: `{ seriesId, dataIndex }`, where `dataIndex` counts skipped slices. Pass `null` to clear the selection while staying controlled. |
|
|
398
|
+
| `defaultSelectedItem?` | `ChartSelectedItem` | — | Initial selected slice when `selectedItem` is omitted. |
|
|
399
|
+
| `onSelectedItemChange?` | `((item: ChartSelectedItem) => void)` | — | Called when a slice or legend row is pressed. Pressing the selected slice again reports `null`. Providing this, `selectedItem`, or `defaultSelectedItem` makes the chart selectable. |
|
|
400
|
+
| `locale?` | `string` | — | BCP 47 locale for default value and share formatting. Defaults to the `@cdx-ui/formatters` locale. |
|
|
401
|
+
| `localeText?` | `Partial<ChartLocaleText>` | — | Overrides for generated strings such as the screen reader summary. |
|
|
402
|
+
| `animation?` | `'disable-all'` | — | Slices sweep in clockwise on mount and tween to new shares when `data` changes. Pass `'disable-all'` to draw the final state. Reduce Motion and `GlobalAnimationSettingsProvider` `disable-all` also turn it off. |
|
|
403
|
+
| `size?` | `'sm' \| 'md' \| 'lg' \| 'xl'` | `'lg'` | Plot box. Named sizes set both width and height; `width` / `height` override one side. |
|
|
404
|
+
| `width?` | `number` | — | Pixel width. Overrides the `size` width. |
|
|
405
|
+
| `height?` | `number` | — | Pixel height. Overrides the `size` height. |
|
|
406
|
+
|
|
407
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
408
|
+
|
|
409
|
+
| Attribute | Values | Description |
|
|
410
|
+
| --------------- | ----------------- | ----------------------------------------------------------------------------------------- |
|
|
411
|
+
| `data-selected` | `true` \| `false` | On each `pie-chart-legend-item` of a selectable chart; `true` on the selected slice's row |
|
|
412
|
+
|
|
413
|
+
### PieChartSeries
|
|
414
|
+
|
|
415
|
+
One entry of `series`.
|
|
416
|
+
|
|
417
|
+
| Prop | Type | Default | Description |
|
|
418
|
+
| --- | --- | --- | --- |
|
|
419
|
+
| `type?` | `'pie'` | — | Series kind. Optional while `PieChart` only draws pies. |
|
|
420
|
+
| `data` | `readonly PieChartValue[]` | — | Slices, drawn clockwise from 12 o'clock in array order. |
|
|
421
|
+
| `innerRadius?` | `number \| `${number}%`` | `0` | Hole radius. A number is pixels; a string such as `'68%'` is a percent of the outer radius. `0` is a full pie. Clamped to 85% of the outer radius. |
|
|
422
|
+
| `paddingAngle?` | `number` | `0` | Degrees between neighboring slices. Skipped on slices too thin to fit it. |
|
|
423
|
+
| `cornerRadius?` | `number` | `0` | Rounds slice corners in pixels. Donuts round all four corners; pies round the outer edge. Clamped so thin slices stay valid. |
|
|
424
|
+
| `shareFormatter?` | `PieShareFormatter` | — | Formats the legend share column and the share in screen reader text. MUI X has no share column, so there is no MUI name. Defaults to a whole percent for `locale`. |
|
|
425
|
+
| `id` | `string` | — | Stable id. `selectedItem.seriesId` and tooltip items refer to it. |
|
|
426
|
+
| `label?` | `string` | — | Series name. Bar and line charts show it in the legend, tooltip, and screen reader text. A pie chart only prefixes tooltip values with it; slice labels name the legend and slices. |
|
|
427
|
+
| `valueFormatter?` | `ChartValueFormatter` | — | Formats this series' values for tooltips and screen reader text, plus bar value labels, line marker values, and a pie's legend value column. `context.location` says where. On charts with axes it wins over the value axis `valueFormatter`. |
|
|
428
|
+
|
|
429
|
+
### PieChartValue
|
|
430
|
+
|
|
431
|
+
One slice in a series `data`.
|
|
432
|
+
|
|
433
|
+
| Prop | Type | Default | Description |
|
|
434
|
+
| --- | --- | --- | --- |
|
|
435
|
+
| `id` | `string` | — | Stable slice id. React keys and animation follow it, so a reordered slice moves to its new position instead of the slices morphing by index. |
|
|
436
|
+
| `value` | `number` | — | Must be a positive finite number. Zero, negative, and `NaN` slices are skipped so they cannot break an arc; `dataIndex` still counts them. |
|
|
437
|
+
| `label?` | `string` | — | Legend, tooltip, and screen reader name. Defaults to `id`. |
|
|
438
|
+
| `color?` | `'danger' \| 'warning' \| 'success' \| 'info' \| 'simple-primary' \| 'simple-secondary' \| 'simple-tertiary' \| 'categorical-1' \| 'categorical-2' \| 'categorical-3' \| 'categorical-4' \| 'categorical-5' \| 'categorical-6'` | — | Chart token for this slice. Defaults to the next `categorical-1`…`6` slot. |
|
|
439
|
+
|
|
440
|
+
### PieChartActiveSlice
|
|
441
|
+
|
|
442
|
+
What a function `centerLabel` receives.
|
|
443
|
+
|
|
444
|
+
| Prop | Type | Default | Description |
|
|
445
|
+
| --- | --- | --- | --- |
|
|
446
|
+
| `id` | `string` | — | The slice `id`. |
|
|
447
|
+
| `dataIndex` | `number` | — | Index into the series `data`, including slices that were skipped. |
|
|
448
|
+
| `label` | `string` | — | The slice `label`, or its `id` when it has none. |
|
|
449
|
+
| `value` | `number` | — | The raw slice `value`, unformatted. |
|
|
450
|
+
| `percentage` | `number` | — | Share of the visible total, from 0 to 1. |
|
|
451
|
+
|
|
452
|
+
### Coming from MUI X
|
|
453
|
+
|
|
454
|
+
`PieChart` follows the MUI X Charts pie API. It is not a wrap of `@mui/x-charts`, and no MUI type appears in its signature.
|
|
455
|
+
|
|
456
|
+
| MUI X | Forge UI | Notes |
|
|
457
|
+
| -------------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
458
|
+
| `series` (`PieSeriesType[]`) | `series` (`PieChartSeries[]`) | Named like `BarChartSeries` and `LineChartSeries`. Only the first series renders. |
|
|
459
|
+
| `series[].data` (`PieValueType[]`) | `series[].data` (`PieChartValue[]`) | `id` is a `string`. `color` is a `ChartColor` token, not a CSS color. |
|
|
460
|
+
| `series[].id` | `series[].id` | `selectedItem.seriesId` refers to it. |
|
|
461
|
+
| `series[].innerRadius` | `series[].innerRadius` | Pixels, or a percent string of the outer radius (`'68%'`). |
|
|
462
|
+
| `series[].outerRadius` | `size`, `width`, `height` | The pie fills the shorter side of the chart box. |
|
|
463
|
+
| `series[].paddingAngle` | `series[].paddingAngle` | Degrees. |
|
|
464
|
+
| `series[].cornerRadius` | `series[].cornerRadius` | Pixels. |
|
|
465
|
+
| `series[].valueFormatter` | `series[].valueFormatter` | Receives the number and `{ location, seriesId, dataIndex }`, not the slice object. |
|
|
466
|
+
| `series[].arcLabel` | `series[].shareFormatter` | `PieChart` draws no arc labels; the share lives in the legend. MUI X has no share column, so there is no MUI name to reuse. |
|
|
467
|
+
| `highlightedItem`, `onHighlightChange` | `selectedItem`, `onSelectedItemChange`, `defaultSelectedItem` | Selection is shared with `BarChart` and `LineChart`. Hover previews are internal. |
|
|
468
|
+
| `hideLegend` | `hideLegend` | Same meaning. |
|
|
469
|
+
| `slotProps.legend.position` | `legendPlacement` | MUI X splits position into `vertical` and `horizontal`. Forge uses one side, matching Drawer `placement`. |
|
|
470
|
+
| `slotProps.legend.direction` | `legendLayout` | `wrap` and `list` are layouts MUI X does not have: `list` adds the amount and share columns. |
|
|
471
|
+
| `slotProps.tooltip.trigger` | `tooltip.trigger` | Default `'item'`. `'axis'` acts like `'item'`; a pie has no axis. |
|
|
472
|
+
| `localeText` | `localeText`, `locale` | `locale` drives the default number and percent format. |
|
|
473
|
+
| `skipAnimation` | `animation="disable-all"` | Same prop as every animated Forge component. |
|
|
474
|
+
| — | `centerLabel` | Content in the donut hole. MUI X composes a custom label element instead. |
|
|
475
|
+
|
|
476
|
+
## Anatomy
|
|
477
|
+
|
|
478
|
+
| `data-slot` | Element |
|
|
479
|
+
| ----------------------- | ---------------- |
|
|
480
|
+
| `pie-chart` | Root |
|
|
481
|
+
| `pie-chart-plot` | Plot |
|
|
482
|
+
| `pie-chart-center` | Donut hole label |
|
|
483
|
+
| `pie-chart-tooltip` | Tooltip |
|
|
484
|
+
| `pie-chart-legend` | Legend |
|
|
485
|
+
| `pie-chart-legend-item` | Legend row |
|
|
486
|
+
|
|
487
|
+
## Accessibility
|
|
488
|
+
|
|
489
|
+
The plot is one image named by `accessibilityLabel`, or by `localeText.pieChartSummary` over each slice's label and share. On a selectable chart, each legend row is a button named by its label and share (in `list` layout, its value too). Focus or hover previews the slice and opens the tooltip; Enter, Space, or a press toggles the selection. A static legend is read as plain text, and the tooltip is always hidden from assistive technology. With `hideLegend`, a selectable chart makes the slices the buttons instead; the plot is then no longer an image, so `accessibilityLabel` is not applied.
|
|
490
|
+
|
|
491
|
+
On native, the buttons announce their selected state. The center label is always hidden from VoiceOver and TalkBack, and the slices are too unless they are buttons, so a total shown only in `centerLabel` is not announced; include it in the summary.
|
|
492
|
+
|
|
493
|
+
On web, the buttons do not expose a selected state to screen readers; selection shows visually and as `data-selected` on legend rows. Slice buttons are not in the Tab order, so keep the legend when keyboard users need to select.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Resources: [Figma](https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-Forge-DS--React-Native-Components?node-id=449-449), [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/feedback-progresssegmented--default)
|
|
4
4
|
|
|
5
|
-
A single (non-compound) component for step-based progress. Pair with a visible step label when WCAG 1.4.1 color-independence is required.
|
|
5
|
+
A single (non-compound) component for step-based progress. Pair with a visible step label when WCAG 1.4.1 color-independence is required. To show a list of named steps instead of a compact meter, use [`Stepper`](https://design.candescent.com/docs/components/stepper/content.md).
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
8
|
import { ProgressSegmented } from '@cdx-ui/components';
|