@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,312 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Chart.tsx
|
|
5
|
+
* @output Root chart container — sets up SVG, scales, and context
|
|
6
|
+
* @position Parent component; all chart marks/axes/interactions are children
|
|
7
|
+
*
|
|
8
|
+
* Handles the d3 margin convention: outer SVG at full size, inner <g> translated
|
|
9
|
+
* by margins. Children receive scales and dimensions via context.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type CSSProperties,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
useMemo,
|
|
16
|
+
useRef,
|
|
17
|
+
useState,
|
|
18
|
+
useCallback,
|
|
19
|
+
useLayoutEffect,
|
|
20
|
+
} from 'react';
|
|
21
|
+
import {scaleLinear, scaleBand} from 'd3-scale';
|
|
22
|
+
import type {ScaleLinear} from 'd3-scale';
|
|
23
|
+
import {isBandScale} from './utils';
|
|
24
|
+
import {ChartProvider} from './ChartContext';
|
|
25
|
+
import type {ChartMargin, ChartScale} from './types';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Controls how the y-axis domain is computed:
|
|
29
|
+
* - `'auto'` — includes 0 when all values are positive (default, bar-friendly)
|
|
30
|
+
* - `'zero'` — symmetric range centered on 0 (good for +/- data)
|
|
31
|
+
* - `'data'` — tight fit to data extent only (no forced zero)
|
|
32
|
+
*/
|
|
33
|
+
export type YBaseline = 'auto' | 'zero' | 'data';
|
|
34
|
+
|
|
35
|
+
export interface ChartProps {
|
|
36
|
+
/** The dataset — array of objects with consistent keys */
|
|
37
|
+
data: Record<string, unknown>[];
|
|
38
|
+
/**
|
|
39
|
+
* Key for the x-axis domain values.
|
|
40
|
+
* String values produce a band scale; numeric values produce a linear scale.
|
|
41
|
+
*/
|
|
42
|
+
xKey: string;
|
|
43
|
+
/**
|
|
44
|
+
* Key(s) for the y-axis domain values.
|
|
45
|
+
* Used to compute the y-domain across all series.
|
|
46
|
+
*/
|
|
47
|
+
yKeys: string[];
|
|
48
|
+
/** Chart height in pixels. Width is responsive (fills container). */
|
|
49
|
+
height?: number;
|
|
50
|
+
/** Override default margins */
|
|
51
|
+
margin?: Partial<ChartMargin>;
|
|
52
|
+
/**
|
|
53
|
+
* How the y-axis domain is computed.
|
|
54
|
+
* - `'auto'` — includes 0 when all values are positive (default)
|
|
55
|
+
* - `'zero'` — symmetric around 0 (use for profit/loss, sentiment, etc.)
|
|
56
|
+
* - `'data'` — tight fit to data extent
|
|
57
|
+
*/
|
|
58
|
+
yBaseline?: YBaseline;
|
|
59
|
+
/**
|
|
60
|
+
* Explicit y-axis domain [min, max].
|
|
61
|
+
* When provided, this is the y-axis range. Data outside it is not clipped
|
|
62
|
+
* visually but will extend beyond the chart area.
|
|
63
|
+
*/
|
|
64
|
+
yDomain?: [number, number];
|
|
65
|
+
/**
|
|
66
|
+
* Explicit x-axis domain [min, max] for linear/time scales.
|
|
67
|
+
* When provided, this is the x-axis range — the chart renders exactly
|
|
68
|
+
* this window. Use for streaming charts where the range shifts over time.
|
|
69
|
+
* Ignored for band (categorical) scales.
|
|
70
|
+
*/
|
|
71
|
+
xDomain?: [number, number];
|
|
72
|
+
/**
|
|
73
|
+
* Set touch-action on the chart container. Use 'none' when interactive
|
|
74
|
+
* components (brush, zoom, crosshair) are present to prevent scroll
|
|
75
|
+
* interference on mobile.
|
|
76
|
+
*/
|
|
77
|
+
interactive?: boolean;
|
|
78
|
+
/** Chart contents — axes, marks, tooltips */
|
|
79
|
+
children: ReactNode;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const DEFAULT_MARGIN: ChartMargin = {top: 16, right: 16, bottom: 32, left: 48};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Root chart container. Computes scales from data and provides them to children.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```
|
|
89
|
+
* <Chart data={data} xKey="month" yKeys={['revenue']} height={300}>
|
|
90
|
+
* <ChartAxis position="bottom" />
|
|
91
|
+
* <ChartAxis position="left" />
|
|
92
|
+
* <ChartBar dataKey="revenue" color={useChartColors().categorical(1)[0]} />
|
|
93
|
+
* </Chart>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export function Chart({
|
|
97
|
+
data,
|
|
98
|
+
xKey,
|
|
99
|
+
yKeys,
|
|
100
|
+
height = 300,
|
|
101
|
+
margin: marginOverride,
|
|
102
|
+
yBaseline = 'auto',
|
|
103
|
+
yDomain: yDomainProp,
|
|
104
|
+
xDomain: xDomainProp,
|
|
105
|
+
interactive = false,
|
|
106
|
+
children,
|
|
107
|
+
}: ChartProps) {
|
|
108
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
109
|
+
const svgRef = useRef<SVGSVGElement>(null);
|
|
110
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
111
|
+
|
|
112
|
+
useLayoutEffect(() => {
|
|
113
|
+
if (!containerRef.current) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const observer = new ResizeObserver(entries => {
|
|
117
|
+
const entry = entries[0];
|
|
118
|
+
if (entry) {
|
|
119
|
+
setContainerWidth(entry.contentRect.width);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
observer.observe(containerRef.current);
|
|
123
|
+
return () => observer.disconnect();
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
// Block scroll/zoom on the container when interactive.
|
|
127
|
+
// Must be non-passive to actually prevent default on touch events.
|
|
128
|
+
useLayoutEffect(() => {
|
|
129
|
+
const el = containerRef.current;
|
|
130
|
+
if (!el || !interactive) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const prevent = (e: TouchEvent) => e.preventDefault();
|
|
134
|
+
el.addEventListener('touchstart', prevent, {passive: false});
|
|
135
|
+
el.addEventListener('touchmove', prevent, {passive: false});
|
|
136
|
+
return () => {
|
|
137
|
+
el.removeEventListener('touchstart', prevent);
|
|
138
|
+
el.removeEventListener('touchmove', prevent);
|
|
139
|
+
};
|
|
140
|
+
}, [interactive]);
|
|
141
|
+
|
|
142
|
+
const margin = useMemo(
|
|
143
|
+
() => ({...DEFAULT_MARGIN, ...marginOverride}),
|
|
144
|
+
[marginOverride],
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const innerWidth = Math.max(0, containerWidth - margin.left - margin.right);
|
|
148
|
+
const innerHeight = Math.max(0, height - margin.top - margin.bottom);
|
|
149
|
+
|
|
150
|
+
const xScale = useMemo((): ChartScale => {
|
|
151
|
+
const xValues = data.map(d => d[xKey]);
|
|
152
|
+
const isNumeric = xValues.every(v => typeof v === 'number');
|
|
153
|
+
|
|
154
|
+
if (isNumeric) {
|
|
155
|
+
if (xDomainProp) {
|
|
156
|
+
// Explicit domain is authoritative — use as-is
|
|
157
|
+
return scaleLinear().domain(xDomainProp).range([0, innerWidth]);
|
|
158
|
+
}
|
|
159
|
+
// Auto-compute from data
|
|
160
|
+
const nums = xValues as number[];
|
|
161
|
+
let min = Infinity;
|
|
162
|
+
let max = -Infinity;
|
|
163
|
+
for (const n of nums) {
|
|
164
|
+
if (n < min) {
|
|
165
|
+
min = n;
|
|
166
|
+
}
|
|
167
|
+
if (n > max) {
|
|
168
|
+
max = n;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return scaleLinear().domain([min, max]).range([0, innerWidth]).nice();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Categorical — xDomain doesn't apply to band scales
|
|
175
|
+
return scaleBand<string>()
|
|
176
|
+
.domain(xValues.map(String))
|
|
177
|
+
.range([0, innerWidth])
|
|
178
|
+
.padding(0.2);
|
|
179
|
+
}, [data, xKey, innerWidth, xDomainProp]);
|
|
180
|
+
|
|
181
|
+
const yScale = useMemo((): ScaleLinear<number, number> => {
|
|
182
|
+
if (yDomainProp) {
|
|
183
|
+
// Explicit domain is authoritative — use as-is.
|
|
184
|
+
// No baseline adjustment, no .nice(). The caller owns the domain
|
|
185
|
+
// (e.g. zoom/pan controls) and rounding would cause ratcheting.
|
|
186
|
+
return scaleLinear().domain(yDomainProp).range([innerHeight, 0]);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Auto-compute from data
|
|
190
|
+
let min = Infinity;
|
|
191
|
+
let max = -Infinity;
|
|
192
|
+
for (const d of data) {
|
|
193
|
+
for (const key of yKeys) {
|
|
194
|
+
const v = d[key];
|
|
195
|
+
if (typeof v === 'number') {
|
|
196
|
+
if (v < min) {
|
|
197
|
+
min = v;
|
|
198
|
+
}
|
|
199
|
+
if (v > max) {
|
|
200
|
+
max = v;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (yBaseline === 'zero') {
|
|
207
|
+
const abs = Math.max(Math.abs(min), Math.abs(max));
|
|
208
|
+
min = -abs;
|
|
209
|
+
max = abs;
|
|
210
|
+
} else if (yBaseline === 'auto') {
|
|
211
|
+
if (min > 0) {
|
|
212
|
+
min = 0;
|
|
213
|
+
}
|
|
214
|
+
if (max < 0) {
|
|
215
|
+
max = 0;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return scaleLinear().domain([min, max]).range([innerHeight, 0]).nice();
|
|
220
|
+
}, [data, yKeys, innerHeight, yBaseline, yDomainProp]);
|
|
221
|
+
|
|
222
|
+
const pixelToData = useCallback(
|
|
223
|
+
(px: number, py: number) => {
|
|
224
|
+
const y = yScale.invert(py);
|
|
225
|
+
let x: number | string;
|
|
226
|
+
if (isBandScale(xScale)) {
|
|
227
|
+
const domain = xScale.domain();
|
|
228
|
+
const step = xScale.step();
|
|
229
|
+
const idx = Math.min(
|
|
230
|
+
domain.length - 1,
|
|
231
|
+
Math.max(0, Math.floor(px / step)),
|
|
232
|
+
);
|
|
233
|
+
x = domain[idx];
|
|
234
|
+
} else {
|
|
235
|
+
x = (xScale as ScaleLinear<number, number>).invert(px);
|
|
236
|
+
}
|
|
237
|
+
return {x, y, px, py};
|
|
238
|
+
},
|
|
239
|
+
[xScale, yScale],
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
const pointerToData = useCallback(
|
|
243
|
+
(e: React.PointerEvent) => {
|
|
244
|
+
const svg = svgRef.current;
|
|
245
|
+
if (!svg) {
|
|
246
|
+
return {x: null, y: 0, px: 0, py: 0};
|
|
247
|
+
}
|
|
248
|
+
const pt = svg.createSVGPoint();
|
|
249
|
+
pt.x = e.clientX;
|
|
250
|
+
pt.y = e.clientY;
|
|
251
|
+
// Transform to the inner <g> coordinate space (accounts for margins)
|
|
252
|
+
const gEl = svg.querySelector('g');
|
|
253
|
+
const ctm = gEl?.getScreenCTM?.()?.inverse();
|
|
254
|
+
const local = ctm ? pt.matrixTransform(ctm) : {x: 0, y: 0};
|
|
255
|
+
return pixelToData(local.x, local.y);
|
|
256
|
+
},
|
|
257
|
+
[pixelToData],
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const ctx = useMemo(
|
|
261
|
+
() => ({
|
|
262
|
+
width: innerWidth,
|
|
263
|
+
height: innerHeight,
|
|
264
|
+
margin,
|
|
265
|
+
xKey,
|
|
266
|
+
data,
|
|
267
|
+
xScale,
|
|
268
|
+
yScale,
|
|
269
|
+
svgRef,
|
|
270
|
+
pointerToData,
|
|
271
|
+
pixelToData,
|
|
272
|
+
}),
|
|
273
|
+
[
|
|
274
|
+
innerWidth,
|
|
275
|
+
innerHeight,
|
|
276
|
+
margin,
|
|
277
|
+
xKey,
|
|
278
|
+
data,
|
|
279
|
+
xScale,
|
|
280
|
+
yScale,
|
|
281
|
+
pointerToData,
|
|
282
|
+
pixelToData,
|
|
283
|
+
],
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
const containerStyle: CSSProperties = {
|
|
287
|
+
width: '100%',
|
|
288
|
+
touchAction: interactive ? 'none' : undefined,
|
|
289
|
+
userSelect: interactive ? 'none' : undefined,
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<div ref={containerRef} style={containerStyle}>
|
|
294
|
+
{containerWidth > 0 && (
|
|
295
|
+
<svg
|
|
296
|
+
ref={svgRef}
|
|
297
|
+
width={containerWidth}
|
|
298
|
+
height={height}
|
|
299
|
+
style={interactive ? {touchAction: 'none'} : undefined}>
|
|
300
|
+
<defs>
|
|
301
|
+
<clipPath id="astryx-chart-plot">
|
|
302
|
+
<rect x={0} y={0} width={innerWidth} height={innerHeight} />
|
|
303
|
+
</clipPath>
|
|
304
|
+
</defs>
|
|
305
|
+
<g transform={`translate(${margin.left},${margin.top})`}>
|
|
306
|
+
<ChartProvider value={ctx}>{children}</ChartProvider>
|
|
307
|
+
</g>
|
|
308
|
+
</svg>
|
|
309
|
+
)}
|
|
310
|
+
</div>
|
|
311
|
+
);
|
|
312
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('../../core/src/docs-types').ComponentDoc} */
|
|
4
|
+
|
|
5
|
+
export const docs = {
|
|
6
|
+
name: 'ChartArea',
|
|
7
|
+
displayName: 'Chart Area',
|
|
8
|
+
group: 'Chart',
|
|
9
|
+
category: 'Data Visualization',
|
|
10
|
+
|
|
11
|
+
usage: {
|
|
12
|
+
description: '',
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
props: [],
|
|
16
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ChartArea.tsx
|
|
5
|
+
* @output Renders a filled area between two y-bounds — confidence intervals, bands, ranges
|
|
6
|
+
* @position Child of Chart; reads scales from context
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {useMemo} from 'react';
|
|
10
|
+
import {area, curveMonotoneX} from 'd3-shape';
|
|
11
|
+
import {useChart} from './ChartContext';
|
|
12
|
+
import {xPixel} from './utils';
|
|
13
|
+
|
|
14
|
+
export interface ChartAreaProps {
|
|
15
|
+
/** Data key for the upper bound. If omitted, uses `baseline`. */
|
|
16
|
+
yUpper?: string;
|
|
17
|
+
/** Data key for the lower bound. If omitted, uses `baseline`. */
|
|
18
|
+
yLower?: string;
|
|
19
|
+
/** Fallback data key when only one bound is specified. */
|
|
20
|
+
baseline?: string;
|
|
21
|
+
/** Fill color */
|
|
22
|
+
color: string;
|
|
23
|
+
/** Fill opacity (default: 0.2) */
|
|
24
|
+
opacity?: number;
|
|
25
|
+
/** Optional stroke on the band edges */
|
|
26
|
+
stroke?: boolean;
|
|
27
|
+
/** Stroke width when stroke is enabled */
|
|
28
|
+
strokeWidth?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Area band between two y-values. Use for confidence intervals, error ranges,
|
|
33
|
+
* or any min/max band around a line.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```
|
|
37
|
+
* <ChartArea yUpper="upper95" yLower="lower95" color={colors[0]} />
|
|
38
|
+
* <ChartArea yUpper="upper95" baseline="mean" color={colors[0]} />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function ChartArea({
|
|
42
|
+
yUpper,
|
|
43
|
+
yLower,
|
|
44
|
+
baseline,
|
|
45
|
+
color,
|
|
46
|
+
opacity = 0.2,
|
|
47
|
+
stroke = false,
|
|
48
|
+
strokeWidth = 1,
|
|
49
|
+
}: ChartAreaProps) {
|
|
50
|
+
const {data, xKey, xScale, yScale} = useChart();
|
|
51
|
+
|
|
52
|
+
const upperKey = yUpper ?? baseline;
|
|
53
|
+
const lowerKey = yLower ?? baseline;
|
|
54
|
+
|
|
55
|
+
const pathD = useMemo(() => {
|
|
56
|
+
if (!upperKey || !lowerKey) {
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
const generator = area<Record<string, unknown>>()
|
|
60
|
+
.x(d => xPixel(d, xKey, xScale))
|
|
61
|
+
.y0(d => {
|
|
62
|
+
const v = typeof d[lowerKey] === 'number' ? (d[lowerKey] as number) : 0;
|
|
63
|
+
return yScale(v);
|
|
64
|
+
})
|
|
65
|
+
.y1(d => {
|
|
66
|
+
const v = typeof d[upperKey] === 'number' ? (d[upperKey] as number) : 0;
|
|
67
|
+
return yScale(v);
|
|
68
|
+
})
|
|
69
|
+
.curve(curveMonotoneX);
|
|
70
|
+
return generator(data) ?? '';
|
|
71
|
+
}, [data, xKey, xScale, yScale, upperKey, lowerKey]);
|
|
72
|
+
|
|
73
|
+
if (!pathD) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<g>
|
|
79
|
+
<path d={pathD} fill={color} fillOpacity={opacity} stroke="none" />
|
|
80
|
+
{stroke && (
|
|
81
|
+
<path
|
|
82
|
+
d={pathD}
|
|
83
|
+
fill="none"
|
|
84
|
+
stroke={color}
|
|
85
|
+
strokeWidth={strokeWidth}
|
|
86
|
+
strokeOpacity={opacity * 2}
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
</g>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ChartAxis.tsx
|
|
5
|
+
* @output Renders an axis (top, right, bottom, left) using the chart's scales
|
|
6
|
+
* @position Child of Chart; reads scales from context
|
|
7
|
+
*
|
|
8
|
+
* Ticks use CSS transitions for smooth sliding during streaming updates.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {useMemo} from 'react';
|
|
12
|
+
import {useChart} from './ChartContext';
|
|
13
|
+
import {isBandScale} from './utils';
|
|
14
|
+
import type {ScaleLinear, ScaleTime} from 'd3-scale';
|
|
15
|
+
|
|
16
|
+
export interface ChartAxisProps {
|
|
17
|
+
/** Which edge to render the axis on */
|
|
18
|
+
position: 'top' | 'right' | 'bottom' | 'left';
|
|
19
|
+
/** Number of ticks (approximate — d3 decides final count) */
|
|
20
|
+
tickCount?: number;
|
|
21
|
+
/** Maximum number of tick labels to show. Labels are evenly skipped when exceeded. */
|
|
22
|
+
maxTicks?: number;
|
|
23
|
+
/** Custom tick formatter */
|
|
24
|
+
tickFormat?: (value: unknown) => string;
|
|
25
|
+
/** Truncate labels to this many characters (appends "\u2026"). */
|
|
26
|
+
truncate?: number;
|
|
27
|
+
/** Enable smooth transitions for streaming (default: true) */
|
|
28
|
+
animated?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Chart axis. Renders tick marks and labels for the x or y dimension.
|
|
33
|
+
* Ticks transition smoothly when the scale domain shifts (e.g. streaming).
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```
|
|
37
|
+
* <ChartAxis position="bottom" />
|
|
38
|
+
* <ChartAxis position="left" tickCount={5} tickFormat={currency} />
|
|
39
|
+
* <ChartAxis position="bottom" maxTicks={6} truncate={10} />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function ChartAxis({
|
|
43
|
+
position,
|
|
44
|
+
tickCount = 5,
|
|
45
|
+
maxTicks,
|
|
46
|
+
tickFormat,
|
|
47
|
+
truncate,
|
|
48
|
+
animated = true,
|
|
49
|
+
}: ChartAxisProps) {
|
|
50
|
+
const {width, height, xScale, yScale} = useChart();
|
|
51
|
+
|
|
52
|
+
const isHorizontal = position === 'top' || position === 'bottom';
|
|
53
|
+
const scale = isHorizontal ? xScale : yScale;
|
|
54
|
+
|
|
55
|
+
const ticks = useMemo(() => {
|
|
56
|
+
let allTicks: {value: unknown; offset: number}[];
|
|
57
|
+
if (isBandScale(scale)) {
|
|
58
|
+
allTicks = scale.domain().map(d => ({
|
|
59
|
+
value: d,
|
|
60
|
+
offset: (scale(d) ?? 0) + scale.bandwidth() / 2,
|
|
61
|
+
}));
|
|
62
|
+
} else {
|
|
63
|
+
const linearScale = scale as
|
|
64
|
+
| ScaleLinear<number, number>
|
|
65
|
+
| ScaleTime<number, number>;
|
|
66
|
+
allTicks = linearScale.ticks(tickCount).map(d => ({
|
|
67
|
+
value: d,
|
|
68
|
+
offset: linearScale(d as number & Date),
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Auto-skip: show every Nth label if maxTicks is exceeded
|
|
73
|
+
if (maxTicks && allTicks.length > maxTicks) {
|
|
74
|
+
const step = Math.ceil(allTicks.length / maxTicks);
|
|
75
|
+
allTicks = allTicks.filter((_, i) => i % step === 0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return allTicks;
|
|
79
|
+
}, [scale, tickCount, maxTicks]);
|
|
80
|
+
|
|
81
|
+
const transform =
|
|
82
|
+
position === 'bottom'
|
|
83
|
+
? `translate(0,${height})`
|
|
84
|
+
: position === 'right'
|
|
85
|
+
? `translate(${width},0)`
|
|
86
|
+
: undefined;
|
|
87
|
+
|
|
88
|
+
// For the bottom axis, draw the axis line at y=0 when the domain spans negative values
|
|
89
|
+
const axisLineY = (() => {
|
|
90
|
+
if (position !== 'bottom') {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
const domain = yScale.domain();
|
|
94
|
+
if (domain[0] < 0 && domain[1] > 0) {
|
|
95
|
+
// The axis line should appear at the zero mark relative to the bottom edge
|
|
96
|
+
return yScale(0) - height;
|
|
97
|
+
}
|
|
98
|
+
return 0;
|
|
99
|
+
})();
|
|
100
|
+
|
|
101
|
+
const baseFormat = tickFormat ?? String;
|
|
102
|
+
const format = truncate
|
|
103
|
+
? (value: unknown) => {
|
|
104
|
+
const str = baseFormat(value);
|
|
105
|
+
return str.length > truncate ? str.slice(0, truncate) + '\u2026' : str;
|
|
106
|
+
}
|
|
107
|
+
: baseFormat;
|
|
108
|
+
const tickSize = 6;
|
|
109
|
+
|
|
110
|
+
// Transition style for smooth tick movement during streaming
|
|
111
|
+
const tickTransition = animated
|
|
112
|
+
? 'transform 150ms linear, opacity 150ms ease'
|
|
113
|
+
: undefined;
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<g transform={transform}>
|
|
117
|
+
{/* Axis line — at y=0 for bottom axis when domain spans negative values */}
|
|
118
|
+
<line
|
|
119
|
+
x1={isHorizontal ? 0 : 0}
|
|
120
|
+
x2={isHorizontal ? width : 0}
|
|
121
|
+
y1={isHorizontal ? axisLineY : 0}
|
|
122
|
+
y2={isHorizontal ? axisLineY : height}
|
|
123
|
+
stroke="var(--color-border-emphasized)"
|
|
124
|
+
strokeWidth={1}
|
|
125
|
+
/>
|
|
126
|
+
{ticks.map(({value, offset}) => {
|
|
127
|
+
const label = format(value);
|
|
128
|
+
// Clip ticks that are outside the visible area
|
|
129
|
+
const isVisible = isHorizontal
|
|
130
|
+
? offset >= -10 && offset <= width + 10
|
|
131
|
+
: offset >= -10 && offset <= height + 10;
|
|
132
|
+
|
|
133
|
+
if (isHorizontal) {
|
|
134
|
+
const y = position === 'bottom' ? tickSize : -tickSize;
|
|
135
|
+
return (
|
|
136
|
+
<g
|
|
137
|
+
key={label}
|
|
138
|
+
style={{
|
|
139
|
+
transform: `translateX(${offset}px)`,
|
|
140
|
+
transition: tickTransition,
|
|
141
|
+
opacity: isVisible ? 1 : 0,
|
|
142
|
+
}}>
|
|
143
|
+
<line
|
|
144
|
+
y2={y}
|
|
145
|
+
stroke="var(--color-border-emphasized)"
|
|
146
|
+
strokeWidth={1}
|
|
147
|
+
/>
|
|
148
|
+
<text
|
|
149
|
+
y={position === 'bottom' ? tickSize + 12 : -(tickSize + 4)}
|
|
150
|
+
textAnchor="middle"
|
|
151
|
+
fill="var(--color-text-secondary)"
|
|
152
|
+
fontSize={12}>
|
|
153
|
+
{label}
|
|
154
|
+
</text>
|
|
155
|
+
</g>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
// Vertical axis
|
|
159
|
+
const x = position === 'left' ? -tickSize : tickSize;
|
|
160
|
+
return (
|
|
161
|
+
<g
|
|
162
|
+
key={label}
|
|
163
|
+
style={{
|
|
164
|
+
transform: `translateY(${offset}px)`,
|
|
165
|
+
transition: tickTransition,
|
|
166
|
+
opacity: isVisible ? 1 : 0,
|
|
167
|
+
}}>
|
|
168
|
+
<line
|
|
169
|
+
x2={x}
|
|
170
|
+
stroke="var(--color-border-emphasized)"
|
|
171
|
+
strokeWidth={1}
|
|
172
|
+
/>
|
|
173
|
+
<text
|
|
174
|
+
x={position === 'left' ? -(tickSize + 4) : tickSize + 4}
|
|
175
|
+
dy="0.32em"
|
|
176
|
+
textAnchor={position === 'left' ? 'end' : 'start'}
|
|
177
|
+
fill="var(--color-text-secondary)"
|
|
178
|
+
fontSize={12}>
|
|
179
|
+
{label}
|
|
180
|
+
</text>
|
|
181
|
+
</g>
|
|
182
|
+
);
|
|
183
|
+
})}
|
|
184
|
+
</g>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('../../core/src/docs-types').ComponentDoc} */
|
|
4
|
+
|
|
5
|
+
export const docs = {
|
|
6
|
+
name: 'ChartBar',
|
|
7
|
+
displayName: 'Chart Bar',
|
|
8
|
+
group: 'Chart',
|
|
9
|
+
category: 'Data Visualization',
|
|
10
|
+
|
|
11
|
+
usage: {
|
|
12
|
+
description: '',
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
props: [],
|
|
16
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ChartBar.tsx
|
|
5
|
+
* @output Renders vertical bars for a data key
|
|
6
|
+
* @position Child of Chart; reads scales from context
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {useChart} from './ChartContext';
|
|
10
|
+
import {isBandScale} from './utils';
|
|
11
|
+
|
|
12
|
+
export interface ChartBarProps {
|
|
13
|
+
/** Which data key to visualize */
|
|
14
|
+
dataKey: string;
|
|
15
|
+
/** Bar fill color (hex string, CSS var, etc.) */
|
|
16
|
+
color: string;
|
|
17
|
+
/** Corner radius on bar tops */
|
|
18
|
+
radius?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Bar marks. Requires a band xScale (categorical x-axis).
|
|
23
|
+
* Bars grow from the zero line — handles both positive and negative values.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```
|
|
27
|
+
* <ChartBar dataKey="revenue" color={useChartColors().categorical(1)[0]} />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function ChartBar({dataKey, color, radius = 4}: ChartBarProps) {
|
|
31
|
+
const {data, xKey, xScale, yScale} = useChart();
|
|
32
|
+
|
|
33
|
+
if (!isBandScale(xScale)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Zero line position — bars grow from here
|
|
38
|
+
const zeroY = yScale(0);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<g>
|
|
42
|
+
{data.map((d, i) => {
|
|
43
|
+
const xVal = xScale(String(d[xKey]));
|
|
44
|
+
if (xVal == null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const yVal =
|
|
49
|
+
typeof d[dataKey] === 'number' ? (d[dataKey] as number) : 0;
|
|
50
|
+
const yPos = yScale(yVal);
|
|
51
|
+
|
|
52
|
+
// Bar grows from zero line toward the value
|
|
53
|
+
const barY = Math.min(yPos, zeroY);
|
|
54
|
+
const barHeight = Math.abs(yPos - zeroY);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<rect
|
|
58
|
+
key={i}
|
|
59
|
+
x={xVal}
|
|
60
|
+
y={barY}
|
|
61
|
+
width={xScale.bandwidth()}
|
|
62
|
+
height={Math.max(0, barHeight)}
|
|
63
|
+
fill={color}
|
|
64
|
+
rx={radius}
|
|
65
|
+
ry={radius}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
})}
|
|
69
|
+
</g>
|
|
70
|
+
);
|
|
71
|
+
}
|