@astryxdesign/lab 0.0.0-bootstrap.0 → 0.1.2-canary.04e71b2
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/CHANGELOG.md +67 -0
- package/LICENSE +21 -0
- package/README.md +47 -1
- package/dist/Chart/Chart.d.ts +77 -0
- package/dist/Chart/Chart.d.ts.map +1 -0
- package/dist/Chart/Chart.js +247 -0
- package/dist/Chart/ChartArea.d.ts +28 -0
- package/dist/Chart/ChartArea.d.ts.map +1 -0
- package/dist/Chart/ChartArea.js +71 -0
- package/dist/Chart/ChartAxis.d.ts +27 -0
- package/dist/Chart/ChartAxis.d.ts.map +1 -0
- package/dist/Chart/ChartAxis.js +147 -0
- package/dist/Chart/ChartBar.d.ts +19 -0
- package/dist/Chart/ChartBar.d.ts.map +1 -0
- package/dist/Chart/ChartBar.js +61 -0
- package/dist/Chart/ChartBrush.d.ts +59 -0
- package/dist/Chart/ChartBrush.d.ts.map +1 -0
- package/dist/Chart/ChartBrush.js +197 -0
- package/dist/Chart/ChartCandlestick.d.ts +50 -0
- package/dist/Chart/ChartCandlestick.d.ts.map +1 -0
- package/dist/Chart/ChartCandlestick.js +138 -0
- package/dist/Chart/ChartContext.d.ts +5 -0
- package/dist/Chart/ChartContext.d.ts.map +1 -0
- package/dist/Chart/ChartContext.js +20 -0
- package/dist/Chart/ChartDot.d.ts +18 -0
- package/dist/Chart/ChartDot.d.ts.map +1 -0
- package/dist/Chart/ChartDot.js +43 -0
- package/dist/Chart/ChartDotGL.d.ts +16 -0
- package/dist/Chart/ChartDotGL.d.ts.map +1 -0
- package/dist/Chart/ChartDotGL.js +135 -0
- package/dist/Chart/ChartDotGLInteractive.d.ts +41 -0
- package/dist/Chart/ChartDotGLInteractive.d.ts.map +1 -0
- package/dist/Chart/ChartDotGLInteractive.js +446 -0
- package/dist/Chart/ChartErrorBar.d.ts +23 -0
- package/dist/Chart/ChartErrorBar.d.ts.map +1 -0
- package/dist/Chart/ChartErrorBar.js +68 -0
- package/dist/Chart/ChartGrid.d.ts +17 -0
- package/dist/Chart/ChartGrid.d.ts.map +1 -0
- package/dist/Chart/ChartGrid.js +67 -0
- package/dist/Chart/ChartHeatmapGL.d.ts +10 -0
- package/dist/Chart/ChartHeatmapGL.d.ts.map +1 -0
- package/dist/Chart/ChartHeatmapGL.js +171 -0
- package/dist/Chart/ChartLegend.d.ts +60 -0
- package/dist/Chart/ChartLegend.d.ts.map +1 -0
- package/dist/Chart/ChartLegend.js +161 -0
- package/dist/Chart/ChartLine.d.ts +23 -0
- package/dist/Chart/ChartLine.d.ts.map +1 -0
- package/dist/Chart/ChartLine.js +64 -0
- package/dist/Chart/ChartReferenceLine.d.ts +11 -0
- package/dist/Chart/ChartReferenceLine.d.ts.map +1 -0
- package/dist/Chart/ChartReferenceLine.js +109 -0
- package/dist/Chart/ChartSelect.d.ts +9 -0
- package/dist/Chart/ChartSelect.d.ts.map +1 -0
- package/dist/Chart/ChartSelect.js +90 -0
- package/dist/Chart/ChartStreamGL.d.ts +17 -0
- package/dist/Chart/ChartStreamGL.d.ts.map +1 -0
- package/dist/Chart/ChartStreamGL.js +157 -0
- package/dist/Chart/ChartTooltip.d.ts +85 -0
- package/dist/Chart/ChartTooltip.d.ts.map +1 -0
- package/dist/Chart/ChartTooltip.js +335 -0
- package/dist/Chart/ChartZoom.d.ts +23 -0
- package/dist/Chart/ChartZoom.d.ts.map +1 -0
- package/dist/Chart/ChartZoom.js +314 -0
- package/dist/Chart/formatters.d.ts +33 -0
- package/dist/Chart/formatters.d.ts.map +1 -0
- package/dist/Chart/formatters.js +101 -0
- package/dist/Chart/getChartColors.d.ts +56 -0
- package/dist/Chart/getChartColors.d.ts.map +1 -0
- package/dist/Chart/getChartColors.js +150 -0
- package/dist/Chart/index.d.ts +29 -0
- package/dist/Chart/index.d.ts.map +1 -0
- package/dist/Chart/index.js +29 -0
- package/dist/Chart/m4.d.ts +36 -0
- package/dist/Chart/m4.d.ts.map +1 -0
- package/dist/Chart/m4.js +106 -0
- package/dist/Chart/types.d.ts +55 -0
- package/dist/Chart/types.d.ts.map +1 -0
- package/dist/Chart/types.js +1 -0
- package/dist/Chart/useChartColors.d.ts +16 -0
- package/dist/Chart/useChartColors.d.ts.map +1 -0
- package/dist/Chart/useChartColors.js +30 -0
- package/dist/Chart/useChartRange.d.ts +50 -0
- package/dist/Chart/useChartRange.d.ts.map +1 -0
- package/dist/Chart/useChartRange.js +90 -0
- package/dist/Chart/utils.d.ts +15 -0
- package/dist/Chart/utils.d.ts.map +1 -0
- package/dist/Chart/utils.js +24 -0
- package/dist/Chart/webgl.d.ts +62 -0
- package/dist/Chart/webgl.d.ts.map +1 -0
- package/dist/Chart/webgl.js +169 -0
- package/dist/ChartV2/Chart.d.ts +32 -0
- package/dist/ChartV2/Chart.d.ts.map +1 -0
- package/dist/ChartV2/Chart.js +281 -0
- package/dist/ChartV2/ChartAxis.d.ts +36 -0
- package/dist/ChartV2/ChartAxis.d.ts.map +1 -0
- package/dist/ChartV2/ChartAxis.js +161 -0
- package/dist/ChartV2/ChartGrid.d.ts +20 -0
- package/dist/ChartV2/ChartGrid.d.ts.map +1 -0
- package/dist/ChartV2/ChartGrid.js +76 -0
- package/dist/ChartV2/ChartLegend.d.ts +14 -0
- package/dist/ChartV2/ChartLegend.d.ts.map +1 -0
- package/dist/ChartV2/ChartLegend.js +54 -0
- package/dist/ChartV2/ChartSwatch.d.ts +36 -0
- package/dist/ChartV2/ChartSwatch.d.ts.map +1 -0
- package/dist/ChartV2/ChartSwatch.js +82 -0
- package/dist/ChartV2/ChartTooltip.d.ts +46 -0
- package/dist/ChartV2/ChartTooltip.d.ts.map +1 -0
- package/dist/ChartV2/ChartTooltip.js +267 -0
- package/dist/ChartV2/ChartV2Context.d.ts +4 -0
- package/dist/ChartV2/ChartV2Context.d.ts.map +1 -0
- package/dist/ChartV2/ChartV2Context.js +12 -0
- package/dist/ChartV2/index.d.ts +13 -0
- package/dist/ChartV2/index.d.ts.map +1 -0
- package/dist/ChartV2/index.js +10 -0
- package/dist/ChartV2/layout.d.ts +25 -0
- package/dist/ChartV2/layout.d.ts.map +1 -0
- package/dist/ChartV2/layout.js +195 -0
- package/dist/ChartV2/legend.d.ts +18 -0
- package/dist/ChartV2/legend.d.ts.map +1 -0
- package/dist/ChartV2/legend.js +24 -0
- package/dist/ChartV2/marks/area.d.ts +19 -0
- package/dist/ChartV2/marks/area.d.ts.map +1 -0
- package/dist/ChartV2/marks/area.js +109 -0
- package/dist/ChartV2/marks/band.d.ts +9 -0
- package/dist/ChartV2/marks/band.d.ts.map +1 -0
- package/dist/ChartV2/marks/band.js +59 -0
- package/dist/ChartV2/marks/bar.d.ts +17 -0
- package/dist/ChartV2/marks/bar.d.ts.map +1 -0
- package/dist/ChartV2/marks/bar.js +120 -0
- package/dist/ChartV2/marks/candlestick.d.ts +15 -0
- package/dist/ChartV2/marks/candlestick.d.ts.map +1 -0
- package/dist/ChartV2/marks/candlestick.js +83 -0
- package/dist/ChartV2/marks/dot.d.ts +15 -0
- package/dist/ChartV2/marks/dot.d.ts.map +1 -0
- package/dist/ChartV2/marks/dot.js +65 -0
- package/dist/ChartV2/marks/dotGL.d.ts +16 -0
- package/dist/ChartV2/marks/dotGL.d.ts.map +1 -0
- package/dist/ChartV2/marks/dotGL.js +178 -0
- package/dist/ChartV2/marks/dotGLInteractive.d.ts +30 -0
- package/dist/ChartV2/marks/dotGLInteractive.d.ts.map +1 -0
- package/dist/ChartV2/marks/dotGLInteractive.js +464 -0
- package/dist/ChartV2/marks/errorBar.d.ts +27 -0
- package/dist/ChartV2/marks/errorBar.d.ts.map +1 -0
- package/dist/ChartV2/marks/errorBar.js +87 -0
- package/dist/ChartV2/marks/heatmapGL.d.ts +23 -0
- package/dist/ChartV2/marks/heatmapGL.d.ts.map +1 -0
- package/dist/ChartV2/marks/heatmapGL.js +242 -0
- package/dist/ChartV2/marks/index.d.ts +13 -0
- package/dist/ChartV2/marks/index.d.ts.map +1 -0
- package/dist/ChartV2/marks/index.js +14 -0
- package/dist/ChartV2/marks/line.d.ts +18 -0
- package/dist/ChartV2/marks/line.d.ts.map +1 -0
- package/dist/ChartV2/marks/line.js +76 -0
- package/dist/ChartV2/marks/referenceLine.d.ts +35 -0
- package/dist/ChartV2/marks/referenceLine.d.ts.map +1 -0
- package/dist/ChartV2/marks/referenceLine.js +186 -0
- package/dist/ChartV2/marks/streamGL.d.ts +36 -0
- package/dist/ChartV2/marks/streamGL.d.ts.map +1 -0
- package/dist/ChartV2/marks/streamGL.js +204 -0
- package/dist/ChartV2/tooltip.d.ts +38 -0
- package/dist/ChartV2/tooltip.d.ts.map +1 -0
- package/dist/ChartV2/tooltip.js +54 -0
- package/dist/ChartV2/types.d.ts +115 -0
- package/dist/ChartV2/types.d.ts.map +1 -0
- package/dist/ChartV2/types.js +35 -0
- package/dist/ChatReasoning/ChatReasoning.d.ts +51 -0
- package/dist/ChatReasoning/ChatReasoning.d.ts.map +1 -0
- package/dist/ChatReasoning/ChatReasoning.js +236 -0
- package/dist/CircularProgress/CircularProgress.d.ts +101 -0
- package/dist/CircularProgress/CircularProgress.d.ts.map +1 -0
- package/dist/CircularProgress/CircularProgress.js +263 -0
- package/dist/CircularProgress/index.d.ts +6 -0
- package/dist/CircularProgress/index.d.ts.map +1 -0
- package/dist/CircularProgress/index.js +8 -0
- package/dist/CodeBlock/index.d.ts +8 -0
- package/dist/CodeBlock/index.d.ts.map +1 -0
- package/dist/CodeBlock/index.js +9 -0
- package/dist/CodeEditor/CodeEditor.d.ts +46 -0
- package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
- package/dist/CodeEditor/CodeEditor.js +396 -0
- package/dist/CodeEditor/index.d.ts +6 -0
- package/dist/CodeEditor/index.d.ts.map +1 -0
- package/dist/CodeEditor/index.js +7 -0
- package/dist/Radial/RadialArea.d.ts +25 -0
- package/dist/Radial/RadialArea.d.ts.map +1 -0
- package/dist/Radial/RadialArea.js +91 -0
- package/dist/Radial/RadialAxis.d.ts +14 -0
- package/dist/Radial/RadialAxis.d.ts.map +1 -0
- package/dist/Radial/RadialAxis.js +55 -0
- package/dist/Radial/RadialChart.d.ts +70 -0
- package/dist/Radial/RadialChart.d.ts.map +1 -0
- package/dist/Radial/RadialChart.js +174 -0
- package/dist/Radial/RadialContext.d.ts +5 -0
- package/dist/Radial/RadialContext.d.ts.map +1 -0
- package/dist/Radial/RadialContext.js +19 -0
- package/dist/Radial/RadialGrid.d.ts +14 -0
- package/dist/Radial/RadialGrid.d.ts.map +1 -0
- package/dist/Radial/RadialGrid.js +70 -0
- package/dist/Radial/RadialSlice.d.ts +23 -0
- package/dist/Radial/RadialSlice.d.ts.map +1 -0
- package/dist/Radial/RadialSlice.js +85 -0
- package/dist/Radial/RadialTooltip.d.ts +44 -0
- package/dist/Radial/RadialTooltip.d.ts.map +1 -0
- package/dist/Radial/RadialTooltip.js +284 -0
- package/dist/Radial/index.d.ts +9 -0
- package/dist/Radial/index.d.ts.map +1 -0
- package/dist/Radial/index.js +9 -0
- package/dist/Radial/types.d.ts +39 -0
- package/dist/Radial/types.d.ts.map +1 -0
- package/dist/Radial/types.js +1 -0
- package/dist/SVGIcon/SVGIcon.d.ts +87 -0
- package/dist/SVGIcon/SVGIcon.d.ts.map +1 -0
- package/dist/SVGIcon/SVGIcon.js +299 -0
- package/dist/SVGIcon/icons.d.ts +49 -0
- package/dist/SVGIcon/icons.d.ts.map +1 -0
- package/dist/SVGIcon/icons.js +326 -0
- package/dist/SVGIcon/index.d.ts +15 -0
- package/dist/SVGIcon/index.d.ts.map +1 -0
- package/dist/SVGIcon/index.js +22 -0
- package/dist/SVGIcon/pathTransforms.d.ts +35 -0
- package/dist/SVGIcon/pathTransforms.d.ts.map +1 -0
- package/dist/SVGIcon/pathTransforms.js +644 -0
- package/dist/SVGIcon/tokens.stylex.d.ts +37 -0
- package/dist/SVGIcon/tokens.stylex.d.ts.map +1 -0
- package/dist/SVGIcon/tokens.stylex.js +40 -0
- package/dist/SVGIcon/variations.stylex.d.ts +44 -0
- package/dist/SVGIcon/variations.stylex.d.ts.map +1 -0
- package/dist/SVGIcon/variations.stylex.js +119 -0
- package/dist/SVGIcon/xif-examples.d.ts +22 -0
- package/dist/SVGIcon/xif-examples.d.ts.map +1 -0
- package/dist/SVGIcon/xif-examples.js +202 -0
- package/dist/SVGIcon/xif-types.d.ts +129 -0
- package/dist/SVGIcon/xif-types.d.ts.map +1 -0
- package/dist/SVGIcon/xif-types.js +1 -0
- package/dist/Sankey/SankeyChart.d.ts +72 -0
- package/dist/Sankey/SankeyChart.d.ts.map +1 -0
- package/dist/Sankey/SankeyChart.js +162 -0
- package/dist/Sankey/SankeyContext.d.ts +5 -0
- package/dist/Sankey/SankeyContext.d.ts.map +1 -0
- package/dist/Sankey/SankeyContext.js +20 -0
- package/dist/Sankey/SankeyGrid.d.ts +20 -0
- package/dist/Sankey/SankeyGrid.d.ts.map +1 -0
- package/dist/Sankey/SankeyGrid.js +53 -0
- package/dist/Sankey/SankeyLabel.d.ts +11 -0
- package/dist/Sankey/SankeyLabel.d.ts.map +1 -0
- package/dist/Sankey/SankeyLabel.js +179 -0
- package/dist/Sankey/SankeyLink.d.ts +29 -0
- package/dist/Sankey/SankeyLink.d.ts.map +1 -0
- package/dist/Sankey/SankeyLink.js +139 -0
- package/dist/Sankey/SankeyNode.d.ts +15 -0
- package/dist/Sankey/SankeyNode.d.ts.map +1 -0
- package/dist/Sankey/SankeyNode.js +56 -0
- package/dist/Sankey/index.d.ts +8 -0
- package/dist/Sankey/index.d.ts.map +1 -0
- package/dist/Sankey/index.js +8 -0
- package/dist/Sankey/layout.d.ts +26 -0
- package/dist/Sankey/layout.d.ts.map +1 -0
- package/dist/Sankey/layout.js +157 -0
- package/dist/Sankey/types.d.ts +84 -0
- package/dist/Sankey/types.d.ts.map +1 -0
- package/dist/Sankey/types.js +1 -0
- package/dist/Schedule/CalendarEvent.d.ts +36 -0
- package/dist/Schedule/CalendarEvent.d.ts.map +1 -0
- package/dist/Schedule/CalendarEvent.js +35 -0
- package/dist/Schedule/DayView.d.ts +8 -0
- package/dist/Schedule/DayView.d.ts.map +1 -0
- package/dist/Schedule/DayView.js +105 -0
- package/dist/Schedule/ListView.d.ts +6 -0
- package/dist/Schedule/ListView.d.ts.map +1 -0
- package/dist/Schedule/ListView.js +171 -0
- package/dist/Schedule/MonthlyView.d.ts +6 -0
- package/dist/Schedule/MonthlyView.d.ts.map +1 -0
- package/dist/Schedule/MonthlyView.js +270 -0
- package/dist/Schedule/Schedule.d.ts +22 -0
- package/dist/Schedule/Schedule.d.ts.map +1 -0
- package/dist/Schedule/Schedule.js +185 -0
- package/dist/Schedule/TimeGridView.d.ts +12 -0
- package/dist/Schedule/TimeGridView.d.ts.map +1 -0
- package/dist/Schedule/TimeGridView.js +364 -0
- package/dist/Schedule/WeeklyView.d.ts +9 -0
- package/dist/Schedule/WeeklyView.d.ts.map +1 -0
- package/dist/Schedule/WeeklyView.js +112 -0
- package/dist/Schedule/context.d.ts +20 -0
- package/dist/Schedule/context.d.ts.map +1 -0
- package/dist/Schedule/context.js +19 -0
- package/dist/Schedule/dateMath.d.ts +21 -0
- package/dist/Schedule/dateMath.d.ts.map +1 -0
- package/dist/Schedule/dateMath.js +63 -0
- package/dist/Schedule/index.d.ts +19 -0
- package/dist/Schedule/index.d.ts.map +1 -0
- package/dist/Schedule/index.js +17 -0
- package/dist/Schedule/plugins/PaginationPlugin.d.ts +7 -0
- package/dist/Schedule/plugins/PaginationPlugin.d.ts.map +1 -0
- package/dist/Schedule/plugins/PaginationPlugin.js +81 -0
- package/dist/Schedule/plugins/ViewSelectorPlugin.d.ts +11 -0
- package/dist/Schedule/plugins/ViewSelectorPlugin.d.ts.map +1 -0
- package/dist/Schedule/plugins/ViewSelectorPlugin.js +78 -0
- package/dist/Schedule/plugins/index.d.ts +5 -0
- package/dist/Schedule/plugins/index.d.ts.map +1 -0
- package/dist/Schedule/plugins/index.js +14 -0
- package/dist/Schedule/shared.d.ts +923 -0
- package/dist/Schedule/shared.d.ts.map +1 -0
- package/dist/Schedule/shared.js +1325 -0
- package/dist/Schedule/types.d.ts +51 -0
- package/dist/Schedule/types.d.ts.map +1 -0
- package/dist/Schedule/types.js +1 -0
- package/dist/Schedule/useCurrentTime.d.ts +3 -0
- package/dist/Schedule/useCurrentTime.d.ts.map +1 -0
- package/dist/Schedule/useCurrentTime.js +43 -0
- package/dist/Schedule/zonedDateTime.d.ts +20 -0
- package/dist/Schedule/zonedDateTime.d.ts.map +1 -0
- package/dist/Schedule/zonedDateTime.js +31 -0
- package/dist/Stepper/Step.d.ts +120 -0
- package/dist/Stepper/Step.d.ts.map +1 -0
- package/dist/Stepper/Step.js +573 -0
- package/dist/Stepper/StepStatus.d.ts +24 -0
- package/dist/Stepper/StepStatus.d.ts.map +1 -0
- package/dist/Stepper/StepStatus.js +1 -0
- package/dist/Stepper/Stepper.d.ts +77 -0
- package/dist/Stepper/Stepper.d.ts.map +1 -0
- package/dist/Stepper/Stepper.js +104 -0
- package/dist/Stepper/StepperContext.d.ts +12 -0
- package/dist/Stepper/StepperContext.d.ts.map +1 -0
- package/dist/Stepper/StepperContext.js +24 -0
- package/dist/Stepper/index.d.ts +8 -0
- package/dist/Stepper/index.d.ts.map +1 -0
- package/dist/Stepper/index.js +7 -0
- package/dist/ThreeD/ThreeDAxis.d.ts +6 -0
- package/dist/ThreeD/ThreeDAxis.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDAxis.js +75 -0
- package/dist/ThreeD/ThreeDBar.d.ts +7 -0
- package/dist/ThreeD/ThreeDBar.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDBar.js +98 -0
- package/dist/ThreeD/ThreeDChart.d.ts +24 -0
- package/dist/ThreeD/ThreeDChart.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDChart.js +202 -0
- package/dist/ThreeD/ThreeDContext.d.ts +5 -0
- package/dist/ThreeD/ThreeDContext.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDContext.js +19 -0
- package/dist/ThreeD/ThreeDGrid.d.ts +5 -0
- package/dist/ThreeD/ThreeDGrid.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDGrid.js +55 -0
- package/dist/ThreeD/ThreeDScatter.d.ts +7 -0
- package/dist/ThreeD/ThreeDScatter.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDScatter.js +57 -0
- package/dist/ThreeD/ThreeDScatterGL.d.ts +7 -0
- package/dist/ThreeD/ThreeDScatterGL.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDScatterGL.js +243 -0
- package/dist/ThreeD/ThreeDSurface.d.ts +15 -0
- package/dist/ThreeD/ThreeDSurface.d.ts.map +1 -0
- package/dist/ThreeD/ThreeDSurface.js +97 -0
- package/dist/ThreeD/index.d.ts +10 -0
- package/dist/ThreeD/index.d.ts.map +1 -0
- package/dist/ThreeD/index.js +10 -0
- package/dist/ThreeD/types.d.ts +57 -0
- package/dist/ThreeD/types.d.ts.map +1 -0
- package/dist/ThreeD/types.js +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/lab.css +423 -0
- package/package.json +69 -4
- package/src/Chart/Chart.tsx +312 -0
- package/src/Chart/ChartArea.doc.mjs +16 -0
- package/src/Chart/ChartArea.tsx +91 -0
- package/src/Chart/ChartAxis.tsx +186 -0
- package/src/Chart/ChartBar.doc.mjs +16 -0
- package/src/Chart/ChartBar.tsx +71 -0
- package/src/Chart/ChartBrush.tsx +237 -0
- package/src/Chart/ChartCandlestick.doc.mjs +16 -0
- package/src/Chart/ChartCandlestick.tsx +186 -0
- package/src/Chart/ChartContext.ts +23 -0
- package/src/Chart/ChartDot.doc.mjs +16 -0
- package/src/Chart/ChartDot.tsx +44 -0
- package/src/Chart/ChartDotGL.doc.mjs +16 -0
- package/src/Chart/ChartDotGL.tsx +151 -0
- package/src/Chart/ChartDotGLInteractive.doc.mjs +16 -0
- package/src/Chart/ChartDotGLInteractive.tsx +519 -0
- package/src/Chart/ChartErrorBar.tsx +84 -0
- package/src/Chart/ChartGrid.tsx +86 -0
- package/src/Chart/ChartHeatmapGL.doc.mjs +16 -0
- package/src/Chart/ChartHeatmapGL.tsx +219 -0
- package/src/Chart/ChartLegend.tsx +181 -0
- package/src/Chart/ChartLine.doc.mjs +16 -0
- package/src/Chart/ChartLine.tsx +70 -0
- package/src/Chart/ChartReferenceLine.tsx +76 -0
- package/src/Chart/ChartSelect.tsx +111 -0
- package/src/Chart/ChartStreamGL.doc.mjs +16 -0
- package/src/Chart/ChartStreamGL.tsx +189 -0
- package/src/Chart/ChartTooltip.tsx +451 -0
- package/src/Chart/ChartZoom.tsx +400 -0
- package/src/Chart/formatters.ts +95 -0
- package/src/Chart/getChartColors.ts +249 -0
- package/src/Chart/index.ts +90 -0
- package/src/Chart/m4.test.ts +66 -0
- package/src/Chart/m4.ts +128 -0
- package/src/Chart/types.ts +64 -0
- package/src/Chart/useChartColors.ts +34 -0
- package/src/Chart/useChartRange.test.ts +101 -0
- package/src/Chart/useChartRange.ts +146 -0
- package/src/Chart/utils.ts +31 -0
- package/src/Chart/webgl.ts +192 -0
- package/src/ChartV2/Chart.tsx +348 -0
- package/src/ChartV2/ChartAxis.tsx +209 -0
- package/src/ChartV2/ChartGrid.tsx +99 -0
- package/src/ChartV2/ChartLegend.tsx +69 -0
- package/src/ChartV2/ChartSwatch.doc.mjs +17 -0
- package/src/ChartV2/ChartSwatch.tsx +86 -0
- package/src/ChartV2/ChartTooltip.tsx +382 -0
- package/src/ChartV2/ChartV2.doc.mjs +16 -0
- package/src/ChartV2/ChartV2Context.ts +15 -0
- package/src/ChartV2/index.ts +62 -0
- package/src/ChartV2/layout.ts +223 -0
- package/src/ChartV2/legend.ts +32 -0
- package/src/ChartV2/marks/area.tsx +122 -0
- package/src/ChartV2/marks/band.tsx +70 -0
- package/src/ChartV2/marks/bar.tsx +159 -0
- package/src/ChartV2/marks/candlestick.tsx +106 -0
- package/src/ChartV2/marks/dot.tsx +64 -0
- package/src/ChartV2/marks/dotGL.tsx +202 -0
- package/src/ChartV2/marks/dotGLInteractive.tsx +546 -0
- package/src/ChartV2/marks/errorBar.tsx +89 -0
- package/src/ChartV2/marks/heatmapGL.tsx +299 -0
- package/src/ChartV2/marks/index.ts +14 -0
- package/src/ChartV2/marks/line.tsx +94 -0
- package/src/ChartV2/marks/referenceLine.tsx +224 -0
- package/src/ChartV2/marks/streamGL.tsx +251 -0
- package/src/ChartV2/tooltip.ts +70 -0
- package/src/ChartV2/types.ts +129 -0
- package/src/ChatReasoning/ChatReasoning.doc.mjs +16 -0
- package/src/ChatReasoning/ChatReasoning.test.tsx +56 -0
- package/src/ChatReasoning/ChatReasoning.tsx +322 -0
- package/src/CircularProgress/CircularProgress.doc.mjs +174 -0
- package/src/CircularProgress/CircularProgress.test.tsx +157 -0
- package/src/CircularProgress/CircularProgress.tsx +373 -0
- package/src/CircularProgress/index.ts +15 -0
- package/src/CodeBlock/index.ts +10 -0
- package/src/CodeEditor/CodeEditor.doc.mjs +16 -0
- package/src/CodeEditor/CodeEditor.tsx +466 -0
- package/src/CodeEditor/index.ts +8 -0
- package/src/Radial/RadialArea.tsx +103 -0
- package/src/Radial/RadialAxis.tsx +60 -0
- package/src/Radial/RadialChart.doc.mjs +16 -0
- package/src/Radial/RadialChart.tsx +219 -0
- package/src/Radial/RadialContext.ts +22 -0
- package/src/Radial/RadialGrid.tsx +81 -0
- package/src/Radial/RadialSlice.tsx +130 -0
- package/src/Radial/RadialTooltip.tsx +347 -0
- package/src/Radial/index.ts +14 -0
- package/src/Radial/types.ts +46 -0
- package/src/SVGIcon/SVGIcon.doc.mjs +16 -0
- package/src/SVGIcon/SVGIcon.tsx +406 -0
- package/src/SVGIcon/icons.ts +283 -0
- package/src/SVGIcon/index.ts +73 -0
- package/src/SVGIcon/pathTransforms.ts +612 -0
- package/src/SVGIcon/tokens.stylex.ts +53 -0
- package/src/SVGIcon/variations.stylex.ts +122 -0
- package/src/SVGIcon/xif-examples.ts +191 -0
- package/src/SVGIcon/xif-types.ts +181 -0
- package/src/Sankey/SankeyChart.doc.mjs +16 -0
- package/src/Sankey/SankeyChart.tsx +220 -0
- package/src/Sankey/SankeyContext.ts +23 -0
- package/src/Sankey/SankeyGrid.tsx +69 -0
- package/src/Sankey/SankeyLabel.tsx +234 -0
- package/src/Sankey/SankeyLink.tsx +167 -0
- package/src/Sankey/SankeyNode.tsx +66 -0
- package/src/Sankey/index.ts +22 -0
- package/src/Sankey/layout.ts +219 -0
- package/src/Sankey/types.ts +93 -0
- package/src/Schedule/CalendarEvent.ts +74 -0
- package/src/Schedule/DayView.tsx +112 -0
- package/src/Schedule/ListView.tsx +236 -0
- package/src/Schedule/MonthlyView.tsx +401 -0
- package/src/Schedule/Schedule.doc.mjs +16 -0
- package/src/Schedule/Schedule.test.tsx +405 -0
- package/src/Schedule/Schedule.tsx +307 -0
- package/src/Schedule/TimeGridView.tsx +589 -0
- package/src/Schedule/WeeklyView.tsx +130 -0
- package/src/Schedule/context.tsx +49 -0
- package/src/Schedule/dateMath.ts +112 -0
- package/src/Schedule/index.ts +61 -0
- package/src/Schedule/plugins/PaginationPlugin.tsx +98 -0
- package/src/Schedule/plugins/ViewSelectorPlugin.tsx +128 -0
- package/src/Schedule/plugins/index.tsx +20 -0
- package/src/Schedule/shared.tsx +1304 -0
- package/src/Schedule/types.ts +86 -0
- package/src/Schedule/useCurrentTime.ts +50 -0
- package/src/Schedule/zonedDateTime.ts +71 -0
- package/src/Stepper/Step.doc.mjs +17 -0
- package/src/Stepper/Step.tsx +756 -0
- package/src/Stepper/StepStatus.ts +26 -0
- package/src/Stepper/Stepper.doc.mjs +265 -0
- package/src/Stepper/Stepper.test.tsx +281 -0
- package/src/Stepper/Stepper.tsx +157 -0
- package/src/Stepper/StepperContext.ts +43 -0
- package/src/Stepper/index.ts +14 -0
- package/src/ThreeD/3DBar.doc.mjs +16 -0
- package/src/ThreeD/3DChart.doc.mjs +16 -0
- package/src/ThreeD/3DScatter.doc.mjs +16 -0
- package/src/ThreeD/3DScatterGL.doc.mjs +16 -0
- package/src/ThreeD/3DSurface.doc.mjs +16 -0
- package/src/ThreeD/ThreeDAxis.tsx +86 -0
- package/src/ThreeD/ThreeDBar.tsx +130 -0
- package/src/ThreeD/ThreeDChart.tsx +262 -0
- package/src/ThreeD/ThreeDContext.ts +22 -0
- package/src/ThreeD/ThreeDGrid.tsx +68 -0
- package/src/ThreeD/ThreeDScatter.tsx +63 -0
- package/src/ThreeD/ThreeDScatterGL.tsx +270 -0
- package/src/ThreeD/ThreeDSurface.tsx +142 -0
- package/src/ThreeD/index.ts +11 -0
- package/src/ThreeD/projection.test.ts +132 -0
- package/src/ThreeD/types.ts +62 -0
- package/src/index.ts +250 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file RadialChart.tsx
|
|
5
|
+
* @output Root radial chart container — spider, pie, donut
|
|
6
|
+
* @position Parent component; all radial marks read from its context
|
|
7
|
+
*
|
|
8
|
+
* Owns the radial coordinate space: center, radius, angle/radius scales.
|
|
9
|
+
* Same Tier 1 guarantee as Chart — all children map through the same context.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type ReactNode,
|
|
14
|
+
useMemo,
|
|
15
|
+
useRef,
|
|
16
|
+
useState,
|
|
17
|
+
useLayoutEffect,
|
|
18
|
+
} from 'react';
|
|
19
|
+
import {RadialProvider} from './RadialContext';
|
|
20
|
+
import type {RadialMode} from './types';
|
|
21
|
+
|
|
22
|
+
export interface RadialChartProps {
|
|
23
|
+
/** The dataset */
|
|
24
|
+
data: Record<string, unknown>[];
|
|
25
|
+
/** Chart height in pixels. Width is responsive. */
|
|
26
|
+
height?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Spider mode: array of axis keys (each key is a dimension).
|
|
29
|
+
* When provided, the chart operates in spider mode.
|
|
30
|
+
*/
|
|
31
|
+
axes?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Pie/donut mode: data key containing the numeric value for each slice.
|
|
34
|
+
* When provided (without axes), the chart operates in pie mode.
|
|
35
|
+
*/
|
|
36
|
+
valueKey?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Pie/donut mode: data key for the slice label.
|
|
39
|
+
*/
|
|
40
|
+
labelKey?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Inner radius as a fraction of outer radius (0-1).
|
|
43
|
+
* 0 = full pie/spider, 0.6 = donut. Default: 0.
|
|
44
|
+
*/
|
|
45
|
+
innerRadius?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Padding between pie slices in radians. Default: 0.02.
|
|
48
|
+
*/
|
|
49
|
+
padAngle?: number;
|
|
50
|
+
/** Chart contents */
|
|
51
|
+
/**
|
|
52
|
+
* Enable touch interaction mode — blocks scroll on mobile.
|
|
53
|
+
*/
|
|
54
|
+
interactive?: boolean;
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Root radial chart container. Computes angular/radial scales and provides
|
|
60
|
+
* them to children via context.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```
|
|
64
|
+
* // Spider
|
|
65
|
+
* <RadialChart data={data} axes={['speed', 'handling', 'comfort']} height={400}>
|
|
66
|
+
* <RadialGrid rings={5} />
|
|
67
|
+
* <RadialArea dataKey="modelA" color={colors[0]} />
|
|
68
|
+
* <RadialAxis />
|
|
69
|
+
* </RadialChart>
|
|
70
|
+
*
|
|
71
|
+
* // Pie
|
|
72
|
+
* <RadialChart data={data} valueKey="revenue" labelKey="region" height={400}>
|
|
73
|
+
* <RadialSlice />
|
|
74
|
+
* </RadialChart>
|
|
75
|
+
*
|
|
76
|
+
* // Donut
|
|
77
|
+
* <RadialChart data={data} valueKey="revenue" labelKey="region" innerRadius={0.6} height={400}>
|
|
78
|
+
* <RadialSlice />
|
|
79
|
+
* </RadialChart>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export function RadialChart({
|
|
83
|
+
data,
|
|
84
|
+
height = 400,
|
|
85
|
+
axes,
|
|
86
|
+
valueKey,
|
|
87
|
+
labelKey,
|
|
88
|
+
innerRadius: innerRadiusFraction = 0,
|
|
89
|
+
padAngle = 0.02,
|
|
90
|
+
children,
|
|
91
|
+
}: RadialChartProps) {
|
|
92
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
93
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
94
|
+
|
|
95
|
+
useLayoutEffect(() => {
|
|
96
|
+
if (!containerRef.current) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const observer = new ResizeObserver(entries => {
|
|
100
|
+
const entry = entries[0];
|
|
101
|
+
if (entry) {
|
|
102
|
+
setContainerWidth(entry.contentRect.width);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
observer.observe(containerRef.current);
|
|
106
|
+
return () => observer.disconnect();
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
const size = Math.min(containerWidth, height);
|
|
110
|
+
const cx = containerWidth / 2;
|
|
111
|
+
const cy = height / 2;
|
|
112
|
+
const outerRadius = size / 2 - 40; // leave room for labels
|
|
113
|
+
const innerRadiusPx = outerRadius * innerRadiusFraction;
|
|
114
|
+
|
|
115
|
+
const mode: RadialMode = axes ? 'spider' : 'pie';
|
|
116
|
+
|
|
117
|
+
// Spider: compute axis angles and domains
|
|
118
|
+
const spiderCtx = useMemo(() => {
|
|
119
|
+
if (!axes || axes.length === 0) {
|
|
120
|
+
return {};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const angleByAxis = new Map<string, number>();
|
|
124
|
+
const step = (2 * Math.PI) / axes.length;
|
|
125
|
+
axes.forEach((key, i) => {
|
|
126
|
+
// Start from top (-PI/2) and go clockwise
|
|
127
|
+
angleByAxis.set(key, -Math.PI / 2 + step * i);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Compute domain per axis
|
|
131
|
+
const axisDomains = new Map<string, [number, number]>();
|
|
132
|
+
for (const key of axes) {
|
|
133
|
+
let min = Infinity;
|
|
134
|
+
let max = -Infinity;
|
|
135
|
+
for (const d of data) {
|
|
136
|
+
const v = d[key];
|
|
137
|
+
if (typeof v === 'number') {
|
|
138
|
+
if (v < min) {
|
|
139
|
+
min = v;
|
|
140
|
+
}
|
|
141
|
+
if (v > max) {
|
|
142
|
+
max = v;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Include 0 as floor
|
|
147
|
+
if (min > 0) {
|
|
148
|
+
min = 0;
|
|
149
|
+
}
|
|
150
|
+
axisDomains.set(key, [min, max]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const radiusScale = (t: number) =>
|
|
154
|
+
innerRadiusPx + t * (outerRadius - innerRadiusPx);
|
|
155
|
+
|
|
156
|
+
return {axes, angleByAxis, radiusScale, axisDomains};
|
|
157
|
+
}, [axes, data, outerRadius, innerRadiusPx]);
|
|
158
|
+
|
|
159
|
+
// Pie: compute slices
|
|
160
|
+
const pieCtx = useMemo(() => {
|
|
161
|
+
if (!valueKey) {
|
|
162
|
+
return {};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const total = data.reduce((sum, d) => {
|
|
166
|
+
const v = d[valueKey];
|
|
167
|
+
return sum + (typeof v === 'number' ? v : 0);
|
|
168
|
+
}, 0);
|
|
169
|
+
|
|
170
|
+
if (total === 0) {
|
|
171
|
+
return {slices: []};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const totalPad = padAngle * data.length;
|
|
175
|
+
const available = 2 * Math.PI - totalPad;
|
|
176
|
+
let currentAngle = -Math.PI / 2; // start from top
|
|
177
|
+
|
|
178
|
+
const slices = data.map(d => {
|
|
179
|
+
const v = typeof d[valueKey] === 'number' ? (d[valueKey] as number) : 0;
|
|
180
|
+
const percentage = v / total;
|
|
181
|
+
const sweep = percentage * available;
|
|
182
|
+
const slice = {
|
|
183
|
+
key: labelKey ? String(d[labelKey]) : String(v),
|
|
184
|
+
value: v,
|
|
185
|
+
startAngle: currentAngle,
|
|
186
|
+
endAngle: currentAngle + sweep,
|
|
187
|
+
percentage,
|
|
188
|
+
};
|
|
189
|
+
currentAngle += sweep + padAngle;
|
|
190
|
+
return slice;
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
return {slices};
|
|
194
|
+
}, [data, valueKey, labelKey, padAngle]);
|
|
195
|
+
|
|
196
|
+
const ctx = useMemo(
|
|
197
|
+
() => ({
|
|
198
|
+
cx,
|
|
199
|
+
cy,
|
|
200
|
+
radius: outerRadius,
|
|
201
|
+
innerRadius: innerRadiusPx,
|
|
202
|
+
data,
|
|
203
|
+
mode,
|
|
204
|
+
...spiderCtx,
|
|
205
|
+
...pieCtx,
|
|
206
|
+
}),
|
|
207
|
+
[cx, cy, outerRadius, innerRadiusPx, data, mode, spiderCtx, pieCtx],
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<div ref={containerRef} style={{width: '100%'}}>
|
|
212
|
+
{containerWidth > 0 && (
|
|
213
|
+
<svg width={containerWidth} height={height}>
|
|
214
|
+
<RadialProvider value={ctx}>{children}</RadialProvider>
|
|
215
|
+
</svg>
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file RadialContext.ts
|
|
5
|
+
* @output React context for radial chart components
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {createContext, useContext} from 'react';
|
|
9
|
+
import type {RadialContext} from './types';
|
|
10
|
+
|
|
11
|
+
const RadialCtx = createContext<RadialContext | null>(null);
|
|
12
|
+
|
|
13
|
+
export const RadialProvider = RadialCtx.Provider;
|
|
14
|
+
|
|
15
|
+
/** Access the radial chart context. Throws if used outside RadialChart. */
|
|
16
|
+
export function useRadial(): RadialContext {
|
|
17
|
+
const ctx = useContext(RadialCtx);
|
|
18
|
+
if (!ctx) {
|
|
19
|
+
throw new Error('Radial components must be used inside <RadialChart>');
|
|
20
|
+
}
|
|
21
|
+
return ctx;
|
|
22
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file RadialGrid.tsx
|
|
5
|
+
* @output Renders concentric grid rings and axis lines for spider charts
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {useRadial} from './RadialContext';
|
|
9
|
+
|
|
10
|
+
export interface RadialGridProps {
|
|
11
|
+
/** Number of concentric rings (default: 5) */
|
|
12
|
+
rings?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Concentric grid rings and axis lines for spider charts.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```
|
|
20
|
+
* <RadialGrid rings={5} />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function RadialGrid({rings = 5}: RadialGridProps) {
|
|
24
|
+
const {cx, cy, radius, innerRadius, axes, angleByAxis, radiusScale} =
|
|
25
|
+
useRadial();
|
|
26
|
+
|
|
27
|
+
if (!axes || !angleByAxis || !radiusScale) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<g>
|
|
33
|
+
{/* Concentric rings */}
|
|
34
|
+
{Array.from({length: rings}, (_, i) => {
|
|
35
|
+
const t = (i + 1) / rings;
|
|
36
|
+
const r = radiusScale(t);
|
|
37
|
+
// Draw polygon ring connecting points at this radius
|
|
38
|
+
const points = axes
|
|
39
|
+
.map(key => {
|
|
40
|
+
const angle = angleByAxis.get(key);
|
|
41
|
+
if (angle == null) {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
return `${cx + Math.cos(angle) * r},${cy + Math.sin(angle) * r}`;
|
|
45
|
+
})
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.join(' ');
|
|
48
|
+
return (
|
|
49
|
+
<polygon
|
|
50
|
+
key={i}
|
|
51
|
+
points={points}
|
|
52
|
+
fill="none"
|
|
53
|
+
stroke="var(--color-border)"
|
|
54
|
+
strokeOpacity={0.3}
|
|
55
|
+
strokeWidth={1}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
})}
|
|
59
|
+
|
|
60
|
+
{/* Axis lines from center to each vertex */}
|
|
61
|
+
{axes.map(key => {
|
|
62
|
+
const angle = angleByAxis.get(key);
|
|
63
|
+
if (angle == null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return (
|
|
67
|
+
<line
|
|
68
|
+
key={key}
|
|
69
|
+
x1={cx + Math.cos(angle) * innerRadius}
|
|
70
|
+
y1={cy + Math.sin(angle) * innerRadius}
|
|
71
|
+
x2={cx + Math.cos(angle) * radius}
|
|
72
|
+
y2={cy + Math.sin(angle) * radius}
|
|
73
|
+
stroke="var(--color-border)"
|
|
74
|
+
strokeOpacity={0.3}
|
|
75
|
+
strokeWidth={1}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
})}
|
|
79
|
+
</g>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file RadialSlice.tsx
|
|
5
|
+
* @output Renders pie/donut slices from radial context
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {useRadial} from './RadialContext';
|
|
9
|
+
|
|
10
|
+
export interface RadialSliceProps {
|
|
11
|
+
/**
|
|
12
|
+
* Colors for each slice. Array of hex strings.
|
|
13
|
+
* Use useChartColors().categorical(n).
|
|
14
|
+
*/
|
|
15
|
+
colors: string[];
|
|
16
|
+
/** Corner radius on slice edges (default: 2) */
|
|
17
|
+
cornerRadius?: number;
|
|
18
|
+
/** Show percentage labels (default: true) */
|
|
19
|
+
labels?: boolean;
|
|
20
|
+
/** Minimum percentage to show a label (default: 5) */
|
|
21
|
+
labelThreshold?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** SVG arc path from angles and radii */
|
|
25
|
+
function arcPath(
|
|
26
|
+
cx: number,
|
|
27
|
+
cy: number,
|
|
28
|
+
innerR: number,
|
|
29
|
+
outerR: number,
|
|
30
|
+
startAngle: number,
|
|
31
|
+
endAngle: number,
|
|
32
|
+
): string {
|
|
33
|
+
const x1 = cx + Math.cos(startAngle) * outerR;
|
|
34
|
+
const y1 = cy + Math.sin(startAngle) * outerR;
|
|
35
|
+
const x2 = cx + Math.cos(endAngle) * outerR;
|
|
36
|
+
const y2 = cy + Math.sin(endAngle) * outerR;
|
|
37
|
+
const x3 = cx + Math.cos(endAngle) * innerR;
|
|
38
|
+
const y3 = cy + Math.sin(endAngle) * innerR;
|
|
39
|
+
const x4 = cx + Math.cos(startAngle) * innerR;
|
|
40
|
+
const y4 = cy + Math.sin(startAngle) * innerR;
|
|
41
|
+
|
|
42
|
+
const sweep = endAngle - startAngle;
|
|
43
|
+
const largeArc = sweep > Math.PI ? 1 : 0;
|
|
44
|
+
|
|
45
|
+
if (innerR === 0) {
|
|
46
|
+
// Pie slice (triangle-ish)
|
|
47
|
+
return [
|
|
48
|
+
`M ${cx} ${cy}`,
|
|
49
|
+
`L ${x1} ${y1}`,
|
|
50
|
+
`A ${outerR} ${outerR} 0 ${largeArc} 1 ${x2} ${y2}`,
|
|
51
|
+
'Z',
|
|
52
|
+
].join(' ');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Donut slice (annular sector)
|
|
56
|
+
return [
|
|
57
|
+
`M ${x1} ${y1}`,
|
|
58
|
+
`A ${outerR} ${outerR} 0 ${largeArc} 1 ${x2} ${y2}`,
|
|
59
|
+
`L ${x3} ${y3}`,
|
|
60
|
+
`A ${innerR} ${innerR} 0 ${largeArc} 0 ${x4} ${y4}`,
|
|
61
|
+
'Z',
|
|
62
|
+
].join(' ');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Pie/donut slices. Reads slice geometry from radial context.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```
|
|
70
|
+
* <RadialSlice colors={colors.categorical(5)} />
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function RadialSlice({
|
|
74
|
+
colors,
|
|
75
|
+
cornerRadius = 0,
|
|
76
|
+
labels = true,
|
|
77
|
+
labelThreshold = 5,
|
|
78
|
+
}: RadialSliceProps) {
|
|
79
|
+
const {cx, cy, radius, innerRadius, slices} = useRadial();
|
|
80
|
+
|
|
81
|
+
if (!slices || slices.length === 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<g>
|
|
87
|
+
{slices.map((slice, i) => {
|
|
88
|
+
const color = colors[i % colors.length];
|
|
89
|
+
const d = arcPath(
|
|
90
|
+
cx,
|
|
91
|
+
cy,
|
|
92
|
+
innerRadius,
|
|
93
|
+
radius,
|
|
94
|
+
slice.startAngle,
|
|
95
|
+
slice.endAngle,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// Label position at midpoint of arc, between inner and outer radius
|
|
99
|
+
const midAngle = (slice.startAngle + slice.endAngle) / 2;
|
|
100
|
+
const labelR = innerRadius + (radius - innerRadius) * 0.6;
|
|
101
|
+
const lx = cx + Math.cos(midAngle) * labelR;
|
|
102
|
+
const ly = cy + Math.sin(midAngle) * labelR;
|
|
103
|
+
const showLabel = labels && slice.percentage * 100 >= labelThreshold;
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<g key={slice.key}>
|
|
107
|
+
<path
|
|
108
|
+
d={d}
|
|
109
|
+
fill={color}
|
|
110
|
+
stroke="var(--color-background-surface)"
|
|
111
|
+
strokeWidth={cornerRadius > 0 ? 0 : 1}
|
|
112
|
+
/>
|
|
113
|
+
{showLabel && (
|
|
114
|
+
<text
|
|
115
|
+
x={lx}
|
|
116
|
+
y={ly}
|
|
117
|
+
textAnchor="middle"
|
|
118
|
+
dominantBaseline="central"
|
|
119
|
+
fill="var(--color-text-primary)"
|
|
120
|
+
fontSize={12}
|
|
121
|
+
fontWeight={500}>
|
|
122
|
+
{Math.round(slice.percentage * 100)}%
|
|
123
|
+
</text>
|
|
124
|
+
)}
|
|
125
|
+
</g>
|
|
126
|
+
);
|
|
127
|
+
})}
|
|
128
|
+
</g>
|
|
129
|
+
);
|
|
130
|
+
}
|