@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,249 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file getChartColors.ts
|
|
5
|
+
* @output Pure function to resolve chart colors from a theme — no React required
|
|
6
|
+
* @position Foundation utility; consumed by useChartColors and non-React contexts
|
|
7
|
+
*
|
|
8
|
+
* Takes a token resolver function (or a defined theme + mode) and returns
|
|
9
|
+
* the full chart colors API. The useChartColors hook wraps this.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type {DefinedTheme} from '@astryxdesign/core/theme';
|
|
13
|
+
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
/** Hue names available in the sequential ramps */
|
|
19
|
+
export type SequentialHue =
|
|
20
|
+
| 'blue'
|
|
21
|
+
| 'shamrock'
|
|
22
|
+
| 'orange'
|
|
23
|
+
| 'pink'
|
|
24
|
+
| 'purple'
|
|
25
|
+
| 'red'
|
|
26
|
+
| 'teal'
|
|
27
|
+
| 'yellow'
|
|
28
|
+
| 'gray';
|
|
29
|
+
|
|
30
|
+
/** The chart colors API returned by both getChartColors and useChartColors */
|
|
31
|
+
export interface ChartColorsAPI {
|
|
32
|
+
categorical(n: number): string[];
|
|
33
|
+
sequential: Record<SequentialHue, (n: number) => string[]>;
|
|
34
|
+
diverging: {
|
|
35
|
+
positiveNegative(n: number): string[];
|
|
36
|
+
coldHot(n: number): string[];
|
|
37
|
+
custom(
|
|
38
|
+
neg: SequentialHue,
|
|
39
|
+
pos: SequentialHue,
|
|
40
|
+
n: number,
|
|
41
|
+
midpoint?: string,
|
|
42
|
+
): string[];
|
|
43
|
+
};
|
|
44
|
+
semantic: {
|
|
45
|
+
positive: string;
|
|
46
|
+
negative: string;
|
|
47
|
+
warning: string;
|
|
48
|
+
neutral: string;
|
|
49
|
+
};
|
|
50
|
+
/** Structural colors for chart chrome — axes, grid, ticks, labels */
|
|
51
|
+
structural: {
|
|
52
|
+
axis: string;
|
|
53
|
+
grid: string;
|
|
54
|
+
tick: string;
|
|
55
|
+
label: string;
|
|
56
|
+
};
|
|
57
|
+
alpha(hex: string, opacity: number): string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A function that resolves a token name to its current value */
|
|
61
|
+
export type TokenResolver = (name: string) => string;
|
|
62
|
+
|
|
63
|
+
// =============================================================================
|
|
64
|
+
// Internals
|
|
65
|
+
// =============================================================================
|
|
66
|
+
|
|
67
|
+
const CATEGORICAL_TOKENS = [
|
|
68
|
+
'--color-data-categorical-blue',
|
|
69
|
+
'--color-data-categorical-orange',
|
|
70
|
+
'--color-data-categorical-purple',
|
|
71
|
+
'--color-data-categorical-green',
|
|
72
|
+
'--color-data-categorical-pink',
|
|
73
|
+
'--color-data-categorical-cyan',
|
|
74
|
+
'--color-data-categorical-red',
|
|
75
|
+
'--color-data-categorical-teal',
|
|
76
|
+
'--color-data-categorical-brown',
|
|
77
|
+
'--color-data-categorical-indigo',
|
|
78
|
+
] as const;
|
|
79
|
+
|
|
80
|
+
const SEQUENTIAL_HUES: SequentialHue[] = [
|
|
81
|
+
'blue',
|
|
82
|
+
'shamrock',
|
|
83
|
+
'orange',
|
|
84
|
+
'pink',
|
|
85
|
+
'purple',
|
|
86
|
+
'red',
|
|
87
|
+
'teal',
|
|
88
|
+
'yellow',
|
|
89
|
+
'gray',
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
function pickFromRamp(stops: string[], n: number): string[] {
|
|
93
|
+
if (n <= 0) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
if (n >= 5) {
|
|
97
|
+
return stops;
|
|
98
|
+
}
|
|
99
|
+
if (n === 1) {
|
|
100
|
+
return [stops[2]];
|
|
101
|
+
}
|
|
102
|
+
return Array.from(
|
|
103
|
+
{length: n},
|
|
104
|
+
(_, i) => stops[Math.round((i * 4) / (n - 1))],
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function hexAlpha(hex: string, opacity: number): string {
|
|
109
|
+
const match = hex.match(
|
|
110
|
+
/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/,
|
|
111
|
+
);
|
|
112
|
+
if (!match) {
|
|
113
|
+
return hex;
|
|
114
|
+
}
|
|
115
|
+
const r = parseInt(match[1], 16);
|
|
116
|
+
const g = parseInt(match[2], 16);
|
|
117
|
+
const b = parseInt(match[3], 16);
|
|
118
|
+
return `rgba(${r},${g},${b},${Math.max(0, Math.min(1, opacity))})`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// =============================================================================
|
|
122
|
+
// Public API
|
|
123
|
+
// =============================================================================
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Build chart colors from a token resolver function.
|
|
127
|
+
* This is the lowest-level API — pass any function that maps token names to values.
|
|
128
|
+
*/
|
|
129
|
+
export function getChartColorsFromResolver(
|
|
130
|
+
resolve: TokenResolver,
|
|
131
|
+
): ChartColorsAPI {
|
|
132
|
+
const categorical = CATEGORICAL_TOKENS.map(t => resolve(t));
|
|
133
|
+
|
|
134
|
+
const ramp = (hue: SequentialHue): string[] =>
|
|
135
|
+
[5, 4, 3, 2, 1].map(step => resolve(`--color-data-${hue}-${step}`));
|
|
136
|
+
|
|
137
|
+
const gray1 = resolve('--color-data-gray-1');
|
|
138
|
+
|
|
139
|
+
function buildDiverging(
|
|
140
|
+
negHue: SequentialHue,
|
|
141
|
+
posHue: SequentialHue,
|
|
142
|
+
n: number,
|
|
143
|
+
midpoint: string = gray1,
|
|
144
|
+
): string[] {
|
|
145
|
+
if (n <= 0) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
if (n === 1) {
|
|
149
|
+
return [midpoint];
|
|
150
|
+
}
|
|
151
|
+
const neg = ramp(negHue);
|
|
152
|
+
const pos = ramp(posHue);
|
|
153
|
+
const half = Math.floor(n / 2);
|
|
154
|
+
const hasCenter = n % 2 === 1;
|
|
155
|
+
const negSide = pickFromRamp(neg, half);
|
|
156
|
+
const posSide = pickFromRamp(pos, half).reverse();
|
|
157
|
+
if (hasCenter) {
|
|
158
|
+
return [...negSide, midpoint, ...posSide];
|
|
159
|
+
}
|
|
160
|
+
return [...negSide, ...posSide];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
categorical(n: number): string[] {
|
|
165
|
+
if (n <= 0) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
return categorical.slice(0, Math.min(n, categorical.length));
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
sequential: Object.fromEntries(
|
|
172
|
+
SEQUENTIAL_HUES.map(hue => [
|
|
173
|
+
hue,
|
|
174
|
+
(n: number): string[] => {
|
|
175
|
+
if (n <= 0) {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
return pickFromRamp(ramp(hue), n);
|
|
179
|
+
},
|
|
180
|
+
]),
|
|
181
|
+
) as Record<SequentialHue, (n: number) => string[]>,
|
|
182
|
+
|
|
183
|
+
diverging: {
|
|
184
|
+
positiveNegative: (n: number) => buildDiverging('shamrock', 'red', n),
|
|
185
|
+
coldHot: (n: number) => buildDiverging('blue', 'red', n),
|
|
186
|
+
custom: (
|
|
187
|
+
neg: SequentialHue,
|
|
188
|
+
pos: SequentialHue,
|
|
189
|
+
n: number,
|
|
190
|
+
mid?: string,
|
|
191
|
+
) => buildDiverging(neg, pos, n, mid),
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
semantic: {
|
|
195
|
+
positive: resolve('--color-data-categorical-green'),
|
|
196
|
+
negative: resolve('--color-data-categorical-red'),
|
|
197
|
+
warning: resolve('--color-data-categorical-orange'),
|
|
198
|
+
neutral: resolve('--color-data-neutral'),
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
structural: {
|
|
202
|
+
axis: resolve('--color-border-emphasized'),
|
|
203
|
+
grid: resolve('--color-border'),
|
|
204
|
+
tick: resolve('--color-border-emphasized'),
|
|
205
|
+
label: resolve('--color-text-secondary'),
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
alpha: hexAlpha,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Build chart colors from a defined theme and color mode.
|
|
214
|
+
*
|
|
215
|
+
* Use this in non-React contexts — WebGL setup, SSR, tests, Node scripts.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```
|
|
219
|
+
* import { neutralTheme } from '@astryxdesign/theme-neutral';
|
|
220
|
+
* const colors = getChartColors(neutralTheme, 'light');
|
|
221
|
+
* colors.categorical(5)
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export function getChartColors(
|
|
225
|
+
theme: DefinedTheme,
|
|
226
|
+
mode: 'light' | 'dark' = 'light',
|
|
227
|
+
): ChartColorsAPI {
|
|
228
|
+
// Build a resolver from the theme's token map
|
|
229
|
+
const resolve: TokenResolver = (name: string) => {
|
|
230
|
+
// Check theme token overrides first, then fall back to defaults
|
|
231
|
+
const raw = theme.tokens?.[name] ?? '';
|
|
232
|
+
if (!raw) {
|
|
233
|
+
return '';
|
|
234
|
+
}
|
|
235
|
+
// Resolve light-dark() for the given mode
|
|
236
|
+
if (raw.startsWith('light-dark(') && raw.endsWith(')')) {
|
|
237
|
+
const inner = raw.slice(11, -1);
|
|
238
|
+
const commaIdx = inner.indexOf(',');
|
|
239
|
+
if (commaIdx !== -1) {
|
|
240
|
+
const light = inner.slice(0, commaIdx).trim();
|
|
241
|
+
const dark = inner.slice(commaIdx + 1).trim();
|
|
242
|
+
return mode === 'light' ? light : dark;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return raw;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
return getChartColorsFromResolver(resolve);
|
|
249
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
export {Chart, type ChartProps, type YBaseline} from './Chart';
|
|
4
|
+
export {ChartAxis, type ChartAxisProps} from './ChartAxis';
|
|
5
|
+
export {
|
|
6
|
+
compactNumber,
|
|
7
|
+
currency,
|
|
8
|
+
percent,
|
|
9
|
+
shortDate,
|
|
10
|
+
monthYear,
|
|
11
|
+
} from './formatters';
|
|
12
|
+
export {ChartGrid, type ChartGridProps} from './ChartGrid';
|
|
13
|
+
export {ChartBar, type ChartBarProps} from './ChartBar';
|
|
14
|
+
export {ChartLine, type ChartLineProps} from './ChartLine';
|
|
15
|
+
export {ChartArea, type ChartAreaProps} from './ChartArea';
|
|
16
|
+
export {ChartErrorBar, type ChartErrorBarProps} from './ChartErrorBar';
|
|
17
|
+
export {
|
|
18
|
+
ChartCandlestick,
|
|
19
|
+
type ChartCandlestickProps,
|
|
20
|
+
} from './ChartCandlestick';
|
|
21
|
+
export {ChartDot, type ChartDotProps} from './ChartDot';
|
|
22
|
+
export {ChartDotGL, type ChartDotGLProps} from './ChartDotGL';
|
|
23
|
+
export {
|
|
24
|
+
ChartDotGLInteractive,
|
|
25
|
+
type ChartDotGLInteractiveProps,
|
|
26
|
+
} from './ChartDotGLInteractive';
|
|
27
|
+
export {
|
|
28
|
+
ChartHeatmapGL,
|
|
29
|
+
type ChartHeatmapGLProps,
|
|
30
|
+
} from './ChartHeatmapGL';
|
|
31
|
+
export {
|
|
32
|
+
ChartStreamGL,
|
|
33
|
+
type ChartStreamGLProps,
|
|
34
|
+
type ChartStreamGLHandle,
|
|
35
|
+
} from './ChartStreamGL';
|
|
36
|
+
export {
|
|
37
|
+
ChartTooltip,
|
|
38
|
+
type ChartTooltipProps,
|
|
39
|
+
type ChartCrosshairMode,
|
|
40
|
+
} from './ChartTooltip';
|
|
41
|
+
export {
|
|
42
|
+
ChartLegend,
|
|
43
|
+
type ChartLegendProps,
|
|
44
|
+
type ChartLegendItem,
|
|
45
|
+
} from './ChartLegend';
|
|
46
|
+
export {useChart} from './ChartContext';
|
|
47
|
+
export type {ChartContext, ChartMargin, ChartScale, DataPoint} from './types';
|
|
48
|
+
export {m4Reduce, type M4Point} from './m4';
|
|
49
|
+
export {isBandScale, xPixel} from './utils';
|
|
50
|
+
export {useChartColors} from './useChartColors';
|
|
51
|
+
export {
|
|
52
|
+
getChartColors,
|
|
53
|
+
getChartColorsFromResolver,
|
|
54
|
+
type ChartColorsAPI,
|
|
55
|
+
type SequentialHue,
|
|
56
|
+
type TokenResolver,
|
|
57
|
+
} from './getChartColors';
|
|
58
|
+
export {
|
|
59
|
+
useChartRange,
|
|
60
|
+
type UseChartRangeOptions,
|
|
61
|
+
type UseChartRangeReturn,
|
|
62
|
+
} from './useChartRange';
|
|
63
|
+
export {
|
|
64
|
+
hexToGL,
|
|
65
|
+
getCanvasDPR,
|
|
66
|
+
getWebGLContext,
|
|
67
|
+
setupGLState,
|
|
68
|
+
sizeCanvas,
|
|
69
|
+
mountCanvasOverSVG,
|
|
70
|
+
compileShader,
|
|
71
|
+
createProgram as createGLProgram,
|
|
72
|
+
CIRCLE_FRAG_BODY,
|
|
73
|
+
POINT_SIZE_COMPENSATION,
|
|
74
|
+
} from './webgl';
|
|
75
|
+
export {
|
|
76
|
+
ChartBrush,
|
|
77
|
+
type ChartBrushProps,
|
|
78
|
+
type BrushMode,
|
|
79
|
+
type BrushRange,
|
|
80
|
+
} from './ChartBrush';
|
|
81
|
+
export {
|
|
82
|
+
ChartZoom,
|
|
83
|
+
type ChartZoomProps,
|
|
84
|
+
type ZoomToolbarPosition,
|
|
85
|
+
} from './ChartZoom';
|
|
86
|
+
export {ChartSelect, type ChartSelectProps} from './ChartSelect';
|
|
87
|
+
export {
|
|
88
|
+
ChartReferenceLine,
|
|
89
|
+
type ChartReferenceLineProps,
|
|
90
|
+
} from './ChartReferenceLine';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, it, expect} from 'vitest';
|
|
4
|
+
import {m4Reduce, type M4Point} from './m4';
|
|
5
|
+
|
|
6
|
+
describe('m4Reduce', () => {
|
|
7
|
+
it('returns empty for empty input', () => {
|
|
8
|
+
expect(m4Reduce([], 100)).toEqual([]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('returns data as-is when small enough', () => {
|
|
12
|
+
const data: M4Point[] = [
|
|
13
|
+
{x: 0, y: 1},
|
|
14
|
+
{x: 1, y: 2},
|
|
15
|
+
{x: 2, y: 3},
|
|
16
|
+
];
|
|
17
|
+
expect(m4Reduce(data, 100)).toEqual(data);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('reduces large dataset', () => {
|
|
21
|
+
// 10k points into 100px width = at most 400 output points
|
|
22
|
+
const data: M4Point[] = Array.from({length: 10000}, (_, i) => ({
|
|
23
|
+
x: i,
|
|
24
|
+
y: Math.sin(i * 0.01) * 100,
|
|
25
|
+
}));
|
|
26
|
+
const reduced = m4Reduce(data, 100);
|
|
27
|
+
expect(reduced.length).toBeLessThanOrEqual(400);
|
|
28
|
+
expect(reduced.length).toBeGreaterThan(0);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('preserves min and max values', () => {
|
|
32
|
+
// Create data with a known spike
|
|
33
|
+
const data: M4Point[] = Array.from({length: 1000}, (_, i) => ({
|
|
34
|
+
x: i,
|
|
35
|
+
y: i === 500 ? 999 : 0,
|
|
36
|
+
}));
|
|
37
|
+
const reduced = m4Reduce(data, 10);
|
|
38
|
+
const maxY = Math.max(...reduced.map(p => p.y));
|
|
39
|
+
expect(maxY).toBe(999); // spike must be preserved
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('preserves first and last points', () => {
|
|
43
|
+
const data: M4Point[] = Array.from({length: 1000}, (_, i) => ({
|
|
44
|
+
x: i,
|
|
45
|
+
y: i,
|
|
46
|
+
}));
|
|
47
|
+
const reduced = m4Reduce(data, 10);
|
|
48
|
+
expect(reduced[0].x).toBe(0);
|
|
49
|
+
expect(reduced[reduced.length - 1].x).toBe(999);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('handles single point', () => {
|
|
53
|
+
const data: M4Point[] = [{x: 5, y: 10}];
|
|
54
|
+
expect(m4Reduce(data, 100)).toEqual([{x: 5, y: 10}]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('respects custom xDomain', () => {
|
|
58
|
+
const data: M4Point[] = Array.from({length: 1000}, (_, i) => ({
|
|
59
|
+
x: i + 500,
|
|
60
|
+
y: i,
|
|
61
|
+
}));
|
|
62
|
+
const reduced = m4Reduce(data, 10, [500, 1499]);
|
|
63
|
+
expect(reduced.length).toBeLessThanOrEqual(40);
|
|
64
|
+
expect(reduced.length).toBeGreaterThan(0);
|
|
65
|
+
});
|
|
66
|
+
});
|
package/src/Chart/m4.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file m4.ts
|
|
5
|
+
* @output m4Reduce — pixel-aware time series data reduction
|
|
6
|
+
* @position Utility consumed by chart line/stream components for large datasets
|
|
7
|
+
*
|
|
8
|
+
* Implements the M4 algorithm from "M4: A Visualization-Oriented Time Series
|
|
9
|
+
* Data Aggregation" (Jugel et al., VLDB 2014).
|
|
10
|
+
*
|
|
11
|
+
* For each pixel column, retains 4 values: first, last, min, max.
|
|
12
|
+
* This is the minimum set needed to visually reproduce a line chart at the
|
|
13
|
+
* target resolution. A 1M-point dataset becomes ~4×width points.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface M4Point {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reduce a time-series dataset to at most 4 points per pixel column.
|
|
23
|
+
*
|
|
24
|
+
* The output preserves all visual features (peaks, troughs, trends) that
|
|
25
|
+
* are distinguishable at the given pixel width. Points within the same
|
|
26
|
+
* pixel column are collapsed to first/min/max/last.
|
|
27
|
+
*
|
|
28
|
+
* @param data — input points, must be sorted by x ascending
|
|
29
|
+
* @param width — chart width in pixels (determines bucket count)
|
|
30
|
+
* @param xDomain — [min, max] of the x-axis. If omitted, derived from data.
|
|
31
|
+
* @returns reduced points (at most 4 × width, typically much fewer)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```
|
|
35
|
+
* // Reduce 100k points to fit a 600px chart
|
|
36
|
+
* const reduced = m4Reduce(rawData, 600);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function m4Reduce(
|
|
40
|
+
data: M4Point[],
|
|
41
|
+
width: number,
|
|
42
|
+
xDomain?: [number, number],
|
|
43
|
+
): M4Point[] {
|
|
44
|
+
if (data.length === 0 || width <= 0) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// If data fits without reduction, return as-is
|
|
49
|
+
if (data.length <= width * 4) {
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const xMin = xDomain ? xDomain[0] : data[0].x;
|
|
54
|
+
const xMax = xDomain ? xDomain[1] : data[data.length - 1].x;
|
|
55
|
+
const xRange = xMax - xMin;
|
|
56
|
+
if (xRange <= 0) {
|
|
57
|
+
return [data[0]];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const bucketCount = Math.ceil(width);
|
|
61
|
+
|
|
62
|
+
// Each bucket tracks: first, last, min, max
|
|
63
|
+
interface Bucket {
|
|
64
|
+
first: M4Point | null;
|
|
65
|
+
last: M4Point | null;
|
|
66
|
+
min: M4Point | null;
|
|
67
|
+
max: M4Point | null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const buckets: Bucket[] = Array.from({length: bucketCount}, () => ({
|
|
71
|
+
first: null,
|
|
72
|
+
last: null,
|
|
73
|
+
min: null,
|
|
74
|
+
max: null,
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
// Single pass through the data
|
|
78
|
+
for (const point of data) {
|
|
79
|
+
const bucketIdx = Math.min(
|
|
80
|
+
bucketCount - 1,
|
|
81
|
+
Math.floor(((point.x - xMin) / xRange) * bucketCount),
|
|
82
|
+
);
|
|
83
|
+
const bucket = buckets[bucketIdx];
|
|
84
|
+
|
|
85
|
+
if (!bucket.first) {
|
|
86
|
+
bucket.first = point;
|
|
87
|
+
bucket.last = point;
|
|
88
|
+
bucket.min = point;
|
|
89
|
+
bucket.max = point;
|
|
90
|
+
} else {
|
|
91
|
+
bucket.last = point;
|
|
92
|
+
if (bucket.min && point.y < bucket.min.y) {
|
|
93
|
+
bucket.min = point;
|
|
94
|
+
}
|
|
95
|
+
if (bucket.max && point.y > bucket.max.y) {
|
|
96
|
+
bucket.max = point;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Emit points in order: first, min, max, last per bucket
|
|
102
|
+
// Sort min/max by x within bucket to maintain temporal order
|
|
103
|
+
const result: M4Point[] = [];
|
|
104
|
+
|
|
105
|
+
for (const bucket of buckets) {
|
|
106
|
+
if (!bucket.first || !bucket.min || !bucket.max || !bucket.last) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const points = [bucket.first, bucket.min, bucket.max, bucket.last];
|
|
111
|
+
|
|
112
|
+
// Deduplicate (some may be the same point)
|
|
113
|
+
const seen = new Set<M4Point>();
|
|
114
|
+
const unique: M4Point[] = [];
|
|
115
|
+
for (const p of points) {
|
|
116
|
+
if (!seen.has(p)) {
|
|
117
|
+
seen.add(p);
|
|
118
|
+
unique.push(p);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Sort by x to maintain line continuity
|
|
123
|
+
unique.sort((a, b) => a.x - b.x);
|
|
124
|
+
result.push(...unique);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file types.ts
|
|
5
|
+
* @output Chart types, scale context, and margin convention
|
|
6
|
+
* @position Foundation types consumed by all chart sub-components
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type {ScaleLinear, ScaleBand, ScaleTime} from 'd3-scale';
|
|
10
|
+
|
|
11
|
+
/** Margin convention for chart SVG */
|
|
12
|
+
export interface ChartMargin {
|
|
13
|
+
top: number;
|
|
14
|
+
right: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
left: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Any d3 scale that maps a domain to a pixel range */
|
|
20
|
+
export type ChartScale =
|
|
21
|
+
| ScaleLinear<number, number>
|
|
22
|
+
| ScaleBand<string>
|
|
23
|
+
| ScaleTime<number, number>;
|
|
24
|
+
|
|
25
|
+
/** Resolved data coordinates from pixel position */
|
|
26
|
+
export interface DataPoint {
|
|
27
|
+
/** X value in data space (number for linear, string for band) */
|
|
28
|
+
x: number | string | null;
|
|
29
|
+
/** Y value in data space */
|
|
30
|
+
y: number;
|
|
31
|
+
/** Pixel x within the plot area */
|
|
32
|
+
px: number;
|
|
33
|
+
/** Pixel y within the plot area */
|
|
34
|
+
py: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Scale context provided by Chart to children */
|
|
38
|
+
export interface ChartContext {
|
|
39
|
+
/** Inner width (SVG width minus margins) */
|
|
40
|
+
width: number;
|
|
41
|
+
/** Inner height (SVG height minus margins) */
|
|
42
|
+
height: number;
|
|
43
|
+
/** Margin offsets */
|
|
44
|
+
margin: ChartMargin;
|
|
45
|
+
/** The data key used for x-axis values */
|
|
46
|
+
xKey: string;
|
|
47
|
+
/** The full dataset */
|
|
48
|
+
data: Record<string, unknown>[];
|
|
49
|
+
/** X scale — band for categorical, linear/time for continuous */
|
|
50
|
+
xScale: ChartScale;
|
|
51
|
+
/** Y scale — typically linear */
|
|
52
|
+
yScale: ScaleLinear<number, number>;
|
|
53
|
+
/** Ref to the SVG element — used for coordinate transforms */
|
|
54
|
+
svgRef: React.RefObject<SVGSVGElement | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Convert a pointer event to data coordinates.
|
|
57
|
+
* Handles SVG coordinate transform (margin offset) automatically.
|
|
58
|
+
*/
|
|
59
|
+
pointerToData: (e: React.PointerEvent) => DataPoint;
|
|
60
|
+
/**
|
|
61
|
+
* Convert pixel coordinates (relative to plot area) to data values.
|
|
62
|
+
*/
|
|
63
|
+
pixelToData: (px: number, py: number) => DataPoint;
|
|
64
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file useChartColors.ts
|
|
5
|
+
* @output Theme-aware chart color palette hook
|
|
6
|
+
* @position React hook wrapping getChartColors — resolves from live theme context
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {useMemo} from 'react';
|
|
10
|
+
import {useTheme} from '@astryxdesign/core/theme';
|
|
11
|
+
import {getChartColorsFromResolver} from './getChartColors';
|
|
12
|
+
import type {ChartColorsAPI} from './getChartColors';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Theme-aware chart colors. Resolves data-viz tokens from the current
|
|
16
|
+
* theme context — respects light/dark mode and custom themes.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```
|
|
20
|
+
* const colors = useChartColors();
|
|
21
|
+
* colors.categorical(5)
|
|
22
|
+
* colors.sequential.blue(3)
|
|
23
|
+
* colors.diverging.positiveNegative(5)
|
|
24
|
+
* colors.alpha('#0171E3', 0.5)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function useChartColors(): ChartColorsAPI {
|
|
28
|
+
const {token} = useTheme();
|
|
29
|
+
|
|
30
|
+
return useMemo(
|
|
31
|
+
() => getChartColorsFromResolver(name => token(name) || ''),
|
|
32
|
+
[token],
|
|
33
|
+
);
|
|
34
|
+
}
|