@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,69 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ChartLegend.tsx
|
|
5
|
+
* @output Standalone chart legend component
|
|
6
|
+
* @position Can be used inside Chart via the `legend` prop, or independently
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Via Chart
|
|
10
|
+
* <Chart legend={{position: 'top', alignment: 'start'}} ... />
|
|
11
|
+
*
|
|
12
|
+
* // Standalone
|
|
13
|
+
* <ChartLegend items={[{label: 'Revenue', color: '#3b82f6'}]} />
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import {Text} from '@astryxdesign/core';
|
|
17
|
+
import {VStack, HStack} from '@astryxdesign/core';
|
|
18
|
+
import {ChartSwatch, swatchVariantForType} from './ChartSwatch';
|
|
19
|
+
import type {LegendItem} from './legend';
|
|
20
|
+
|
|
21
|
+
export type {LegendItem};
|
|
22
|
+
|
|
23
|
+
export type LegendPosition = 'top' | 'bottom' | 'start' | 'end';
|
|
24
|
+
export type LegendAlignment = 'start' | 'center' | 'end';
|
|
25
|
+
|
|
26
|
+
export interface ChartLegendProps {
|
|
27
|
+
/** Legend items to display */
|
|
28
|
+
items?: LegendItem[];
|
|
29
|
+
/** Position of the legend relative to the chart. Default: 'bottom' */
|
|
30
|
+
position?: LegendPosition;
|
|
31
|
+
/** Alignment of the legend within its position. Default: 'start' */
|
|
32
|
+
alignment?: LegendAlignment;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function ChartLegend({
|
|
36
|
+
items = [],
|
|
37
|
+
position = 'bottom',
|
|
38
|
+
alignment = 'start',
|
|
39
|
+
}: ChartLegendProps) {
|
|
40
|
+
if (items.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const isVertical = position === 'start' || position === 'end';
|
|
45
|
+
|
|
46
|
+
const legendItems = items.map(item => (
|
|
47
|
+
<HStack key={item.label} gap={2} vAlign="center">
|
|
48
|
+
<ChartSwatch
|
|
49
|
+
color={item.color}
|
|
50
|
+
variant={swatchVariantForType(item.type)}
|
|
51
|
+
/>
|
|
52
|
+
<Text type="supporting">{item.label}</Text>
|
|
53
|
+
</HStack>
|
|
54
|
+
));
|
|
55
|
+
|
|
56
|
+
if (isVertical) {
|
|
57
|
+
return (
|
|
58
|
+
<VStack gap={2} hAlign={alignment}>
|
|
59
|
+
{legendItems}
|
|
60
|
+
</VStack>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<HStack gap={4} justify={alignment} vAlign="center" wrap="wrap">
|
|
66
|
+
{legendItems}
|
|
67
|
+
</HStack>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('../../core/src/docs-types').ComponentDoc} */
|
|
4
|
+
|
|
5
|
+
export const docs = {
|
|
6
|
+
name: 'ChartSwatch',
|
|
7
|
+
displayName: 'Chart Swatch',
|
|
8
|
+
group: 'ChartV2',
|
|
9
|
+
category: 'Data Visualization',
|
|
10
|
+
isHiddenFromOverview: true,
|
|
11
|
+
|
|
12
|
+
usage: {
|
|
13
|
+
description: '',
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
props: [],
|
|
17
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ChartSwatch.tsx
|
|
5
|
+
* @output Color swatch primitive for legends, tooltips, and standalone use
|
|
6
|
+
* @position Composable primitive — used by ChartLegend (and future
|
|
7
|
+
* ChartTooltip), or independently anywhere a series indicator
|
|
8
|
+
* is needed.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* <ChartSwatch color="#3b82f6" variant="square" />
|
|
13
|
+
* <ChartSwatch color="#f59e0b" variant="line" />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {memo} from 'react';
|
|
18
|
+
import * as stylex from '@stylexjs/stylex';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Visual variant — drives shape.
|
|
22
|
+
* - `'square'` — square chip (bar series)
|
|
23
|
+
* - `'line'` — short stroke (line, dot, area, and other non-bar series)
|
|
24
|
+
*/
|
|
25
|
+
export type ChartSwatchVariant = 'square' | 'line';
|
|
26
|
+
|
|
27
|
+
export interface ChartSwatchProps {
|
|
28
|
+
/** Fill color — typically a series color token */
|
|
29
|
+
color: string;
|
|
30
|
+
/** Visual variant. Default: `'square'`. */
|
|
31
|
+
variant?: ChartSwatchVariant;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const styles = stylex.create({
|
|
35
|
+
base: {
|
|
36
|
+
flexShrink: 0,
|
|
37
|
+
},
|
|
38
|
+
square: {
|
|
39
|
+
width: 8,
|
|
40
|
+
height: 8,
|
|
41
|
+
borderRadius: 2,
|
|
42
|
+
marginInline: 1,
|
|
43
|
+
},
|
|
44
|
+
line: {
|
|
45
|
+
width: 10,
|
|
46
|
+
height: 3,
|
|
47
|
+
borderRadius: 1.5,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Color swatch primitive.
|
|
53
|
+
*
|
|
54
|
+
* Used by ChartLegend (and ChartTooltip) to render the colored
|
|
55
|
+
* indicator next to a series label. Exported as a primitive so consumers
|
|
56
|
+
* can build their own custom legend/tooltip layouts while keeping visuals
|
|
57
|
+
* consistent.
|
|
58
|
+
*/
|
|
59
|
+
function ChartSwatchImpl({color, variant = 'square'}: ChartSwatchProps) {
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
aria-hidden
|
|
63
|
+
{...stylex.props(styles.base, styles[variant])}
|
|
64
|
+
style={{backgroundColor: color}}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Memoized — swatches are static for a given (color, variant) tuple
|
|
71
|
+
* and can render many times in a tooltip/legend with several series.
|
|
72
|
+
*/
|
|
73
|
+
export const ChartSwatch = memo(ChartSwatchImpl);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Map a SeriesDef.type string to its swatch variant.
|
|
77
|
+
*
|
|
78
|
+
* Bar series get a square chip; everything else (line, dot, area, and any
|
|
79
|
+
* other non-bar mark) gets a short stroke. Centralized so legend, tooltip,
|
|
80
|
+
* and any custom chrome stay consistent.
|
|
81
|
+
*/
|
|
82
|
+
export function swatchVariantForType(
|
|
83
|
+
type: string | undefined,
|
|
84
|
+
): ChartSwatchVariant {
|
|
85
|
+
return type === 'bar' ? 'square' : 'line';
|
|
86
|
+
}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ChartTooltip.tsx
|
|
5
|
+
* @output Grouped chart tooltip — shows all series values at the hovered x-position.
|
|
6
|
+
* Composable: drop into `<Chart tooltip>` or render directly inside a chart
|
|
7
|
+
* to take full control of props.
|
|
8
|
+
* @position Reads from ChartV2Context — must render inside an <Chart>.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* // Default — declarative on Chart
|
|
13
|
+
* <Chart tooltip />
|
|
14
|
+
*
|
|
15
|
+
* // Custom render function via Chart prop
|
|
16
|
+
* <Chart tooltip={{render: (x, rows) => <MyCard x={x} rows={rows} />}} />
|
|
17
|
+
*
|
|
18
|
+
* // Composable — drop into the chart's children for full control
|
|
19
|
+
* <Chart>
|
|
20
|
+
* <ChartTooltip hoverIndicator={false} placement="top" />
|
|
21
|
+
* </Chart>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
'use client';
|
|
26
|
+
|
|
27
|
+
import {
|
|
28
|
+
memo,
|
|
29
|
+
useState,
|
|
30
|
+
useEffect,
|
|
31
|
+
useMemo,
|
|
32
|
+
useRef,
|
|
33
|
+
useCallback,
|
|
34
|
+
type ReactNode,
|
|
35
|
+
} from 'react';
|
|
36
|
+
import {createPortal} from 'react-dom';
|
|
37
|
+
import * as stylex from '@stylexjs/stylex';
|
|
38
|
+
import {
|
|
39
|
+
colorVars,
|
|
40
|
+
radiusVars,
|
|
41
|
+
shadowVars,
|
|
42
|
+
spacingVars,
|
|
43
|
+
} from '@astryxdesign/core/theme/tokens.stylex';
|
|
44
|
+
import {Text} from '@astryxdesign/core';
|
|
45
|
+
import {VStack, HStack} from '@astryxdesign/core';
|
|
46
|
+
import {useChartV2} from './ChartV2Context';
|
|
47
|
+
import {ChartSwatch, swatchVariantForType} from './ChartSwatch';
|
|
48
|
+
import {
|
|
49
|
+
deriveTooltipSeriesValues,
|
|
50
|
+
shouldRenderHoverDot,
|
|
51
|
+
type TooltipSeriesValue,
|
|
52
|
+
} from './tooltip';
|
|
53
|
+
import type {SeriesDef, ChartPointerEvent} from './types';
|
|
54
|
+
import type {ScaleBand} from 'd3-scale';
|
|
55
|
+
|
|
56
|
+
export type ChartTooltipPlacement = 'auto' | 'right' | 'left' | 'top';
|
|
57
|
+
|
|
58
|
+
export interface ChartTooltipProps {
|
|
59
|
+
/**
|
|
60
|
+
* Series definitions — used to map the hovered datum to per-series rows.
|
|
61
|
+
* When rendered via `<Chart tooltip />`, Chart injects this automatically.
|
|
62
|
+
* When composing directly, pass the same `series` array you gave Chart.
|
|
63
|
+
*/
|
|
64
|
+
series?: readonly SeriesDef[];
|
|
65
|
+
/**
|
|
66
|
+
* Custom render function. Receives the x-value and one row per visible series.
|
|
67
|
+
* Returning `null` hides the card while still rendering the band highlight + dots.
|
|
68
|
+
*/
|
|
69
|
+
render?: (xValue: unknown, seriesValues: TooltipSeriesValue[]) => ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Whether to draw a hover indicator at the focused x-position.
|
|
72
|
+
* Picks the right shape automatically:
|
|
73
|
+
* - **band-highlight rect** when the chart includes bar series on a band scale
|
|
74
|
+
* - **vertical crosshair line** for line / area / dot charts
|
|
75
|
+
*
|
|
76
|
+
* Default: `true`.
|
|
77
|
+
*/
|
|
78
|
+
hoverIndicator?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether to draw a hover dot at each series' point (skipped for bars).
|
|
81
|
+
* Default: `true`.
|
|
82
|
+
*/
|
|
83
|
+
showHoverDots?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Card placement relative to the hovered point:
|
|
86
|
+
* - `'auto'` (default): right of the point, flips to left if it would overflow
|
|
87
|
+
* - `'right'` / `'left'` / `'top'`: pinned position
|
|
88
|
+
*/
|
|
89
|
+
placement?: ChartTooltipPlacement;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const styles = stylex.create({
|
|
93
|
+
// Card chrome — static visual styles. Position (left/top/display) is updated
|
|
94
|
+
// imperatively via ref to keep pointer-move cost free of React renders.
|
|
95
|
+
card: {
|
|
96
|
+
position: 'fixed',
|
|
97
|
+
backgroundColor: colorVars['--color-background-popover'],
|
|
98
|
+
border: `1px solid ${colorVars['--color-border']}`,
|
|
99
|
+
borderRadius: radiusVars['--radius-container'],
|
|
100
|
+
paddingBlock: spacingVars['--spacing-2'],
|
|
101
|
+
paddingInline: spacingVars['--spacing-3'],
|
|
102
|
+
boxShadow: shadowVars['--shadow-med'],
|
|
103
|
+
pointerEvents: 'none',
|
|
104
|
+
whiteSpace: 'nowrap',
|
|
105
|
+
zIndex: 9999,
|
|
106
|
+
display: 'none',
|
|
107
|
+
},
|
|
108
|
+
crosshair: {
|
|
109
|
+
stroke: colorVars['--color-text-primary'],
|
|
110
|
+
strokeWidth: 1,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
/** Default tooltip body — used when `render` is not provided. */
|
|
115
|
+
const DefaultTooltipContent = memo(function DefaultTooltipContent({
|
|
116
|
+
xValue,
|
|
117
|
+
rows,
|
|
118
|
+
}: {
|
|
119
|
+
xValue: unknown;
|
|
120
|
+
rows: TooltipSeriesValue[];
|
|
121
|
+
}) {
|
|
122
|
+
return (
|
|
123
|
+
<VStack gap={1}>
|
|
124
|
+
<Text type="body" weight="semibold">
|
|
125
|
+
{String(xValue)}
|
|
126
|
+
</Text>
|
|
127
|
+
{rows.length === 1 ? (
|
|
128
|
+
<Text type="supporting">{String(rows[0].value)}</Text>
|
|
129
|
+
) : (
|
|
130
|
+
<VStack gap={1}>
|
|
131
|
+
{rows.map(row => (
|
|
132
|
+
<HStack key={row.key} gap={2} vAlign="center">
|
|
133
|
+
<ChartSwatch
|
|
134
|
+
color={row.color}
|
|
135
|
+
variant={swatchVariantForType(row.type)}
|
|
136
|
+
/>
|
|
137
|
+
<Text type="supporting">{row.label}</Text>
|
|
138
|
+
<Text type="supporting" weight="semibold">
|
|
139
|
+
{String(row.value)}
|
|
140
|
+
</Text>
|
|
141
|
+
</HStack>
|
|
142
|
+
))}
|
|
143
|
+
</VStack>
|
|
144
|
+
)}
|
|
145
|
+
</VStack>
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Composable grouped tooltip for Chart.
|
|
151
|
+
*
|
|
152
|
+
* Subscribes to the chart's pointer event stream and only re-renders when the
|
|
153
|
+
* hovered data index changes (not on every pointer move). Card position is
|
|
154
|
+
* updated imperatively via a ref to keep pointer-move cost ~free.
|
|
155
|
+
*/
|
|
156
|
+
export function ChartTooltip({
|
|
157
|
+
series = [],
|
|
158
|
+
render,
|
|
159
|
+
hoverIndicator = true,
|
|
160
|
+
showHoverDots = true,
|
|
161
|
+
placement = 'auto',
|
|
162
|
+
}: ChartTooltipProps) {
|
|
163
|
+
const {
|
|
164
|
+
data,
|
|
165
|
+
xKey,
|
|
166
|
+
resolved,
|
|
167
|
+
onPointer,
|
|
168
|
+
svgRef,
|
|
169
|
+
margin,
|
|
170
|
+
xScale,
|
|
171
|
+
width,
|
|
172
|
+
height,
|
|
173
|
+
} = useChartV2();
|
|
174
|
+
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
|
|
175
|
+
const cardRef = useRef<HTMLDivElement>(null);
|
|
176
|
+
|
|
177
|
+
// Stable Set of resolved series keys — used by deriveTooltipSeriesValues.
|
|
178
|
+
// Recomputed only when the resolved map identity changes (per layout pass).
|
|
179
|
+
const resolvedKeys = useMemo(() => new Set(resolved.keys()), [resolved]);
|
|
180
|
+
|
|
181
|
+
// ─── Card positioning ──────────────────────────────────────────────────
|
|
182
|
+
// Imperative — the card is portaled, and we don't want pointer-move to
|
|
183
|
+
// trigger React renders.
|
|
184
|
+
const positionCard = useCallback(
|
|
185
|
+
(e: ChartPointerEvent) => {
|
|
186
|
+
const card = cardRef.current;
|
|
187
|
+
const svg = svgRef.current;
|
|
188
|
+
if (!card) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (!svg || !e.nearest) {
|
|
192
|
+
card.style.display = 'none';
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const svgRect = svg.getBoundingClientRect();
|
|
196
|
+
const screenX = svgRect.left + margin.left + e.nearest.px;
|
|
197
|
+
const screenY = svgRect.top + margin.top;
|
|
198
|
+
const cardWidth = card.offsetWidth;
|
|
199
|
+
const cardHeight = card.offsetHeight;
|
|
200
|
+
const viewportWidth = window.innerWidth;
|
|
201
|
+
const gap = 8;
|
|
202
|
+
|
|
203
|
+
let x: number;
|
|
204
|
+
let y = screenY;
|
|
205
|
+
switch (placement) {
|
|
206
|
+
case 'left':
|
|
207
|
+
x = screenX - cardWidth - gap;
|
|
208
|
+
break;
|
|
209
|
+
case 'right':
|
|
210
|
+
x = screenX + gap;
|
|
211
|
+
break;
|
|
212
|
+
case 'top':
|
|
213
|
+
x = screenX - cardWidth / 2;
|
|
214
|
+
y = screenY - cardHeight - gap;
|
|
215
|
+
break;
|
|
216
|
+
case 'auto':
|
|
217
|
+
default: {
|
|
218
|
+
const rightX = screenX + gap;
|
|
219
|
+
x =
|
|
220
|
+
rightX + cardWidth > viewportWidth
|
|
221
|
+
? screenX - cardWidth - gap
|
|
222
|
+
: rightX;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
card.style.left = `${x}px`;
|
|
227
|
+
card.style.top = `${y}px`;
|
|
228
|
+
card.style.display = 'block';
|
|
229
|
+
},
|
|
230
|
+
[svgRef, margin, placement],
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
// ─── Subscribe to pointer events ───────────────────────────────────────
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
let currentIndex: number | null = null;
|
|
236
|
+
const unsub = onPointer((e: ChartPointerEvent) => {
|
|
237
|
+
const newIndex = e.nearest?.dataIndex ?? null;
|
|
238
|
+
if (newIndex !== currentIndex) {
|
|
239
|
+
currentIndex = newIndex;
|
|
240
|
+
setHoveredIndex(newIndex);
|
|
241
|
+
}
|
|
242
|
+
positionCard(e);
|
|
243
|
+
});
|
|
244
|
+
return unsub;
|
|
245
|
+
}, [onPointer, positionCard]);
|
|
246
|
+
|
|
247
|
+
// ─── Derived data ──────────────────────────────────────────────────────
|
|
248
|
+
const datum = hoveredIndex != null ? data[hoveredIndex] : undefined;
|
|
249
|
+
const xValue = datum?.[xKey];
|
|
250
|
+
|
|
251
|
+
const seriesValues = useMemo(
|
|
252
|
+
() => deriveTooltipSeriesValues(series, datum, resolvedKeys),
|
|
253
|
+
[series, datum, resolvedKeys],
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
// Hover dots — read from the resolved map at the hovered index.
|
|
257
|
+
const dots = useMemo(() => {
|
|
258
|
+
if (!showHoverDots || hoveredIndex == null) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
const elements: ReactNode[] = [];
|
|
262
|
+
for (const s of series) {
|
|
263
|
+
if (!shouldRenderHoverDot(s.type)) {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const points = resolved.get(s.key);
|
|
267
|
+
const point = points?.find(p => p.dataIndex === hoveredIndex);
|
|
268
|
+
if (!point) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
elements.push(
|
|
272
|
+
<circle
|
|
273
|
+
key={s.key}
|
|
274
|
+
cx={point.px}
|
|
275
|
+
cy={point.py}
|
|
276
|
+
r={4}
|
|
277
|
+
fill="var(--color-background-surface)"
|
|
278
|
+
stroke={s.color ?? 'var(--color-border-emphasized)'}
|
|
279
|
+
strokeWidth={2}
|
|
280
|
+
pointerEvents="none"
|
|
281
|
+
/>,
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
return elements;
|
|
285
|
+
}, [showHoverDots, hoveredIndex, series, resolved]);
|
|
286
|
+
|
|
287
|
+
// Hover indicator — band-highlight rect for bar charts, vertical crosshair
|
|
288
|
+
// line for line/area charts. Same source-of-truth (hoveredIndex), distinct
|
|
289
|
+
// visual idioms picked automatically based on the series mix.
|
|
290
|
+
const hoverIndicatorElement = useMemo(() => {
|
|
291
|
+
if (!hoverIndicator || hoveredIndex == null) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
const xv = data[hoveredIndex]?.[xKey];
|
|
295
|
+
if (xv == null) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const isBandScale = 'bandwidth' in xScale;
|
|
299
|
+
const hasBars = series.some(s => s.type === 'bar');
|
|
300
|
+
|
|
301
|
+
// Bar charts on a band scale → soft column highlight.
|
|
302
|
+
if (hasBars && isBandScale) {
|
|
303
|
+
const bandScale = xScale as ScaleBand<string>;
|
|
304
|
+
const x = bandScale(String(xv)) ?? 0;
|
|
305
|
+
const bw = bandScale.bandwidth();
|
|
306
|
+
const pad = 8;
|
|
307
|
+
const rectX = Math.max(0, x - pad);
|
|
308
|
+
const rectRight = Math.min(width, x + bw + pad);
|
|
309
|
+
const rectWidth = rectRight - rectX;
|
|
310
|
+
const topPad = Math.min(pad, margin.top);
|
|
311
|
+
return (
|
|
312
|
+
<rect
|
|
313
|
+
x={rectX}
|
|
314
|
+
y={-topPad}
|
|
315
|
+
width={rectWidth}
|
|
316
|
+
height={height + topPad}
|
|
317
|
+
fill="currentColor"
|
|
318
|
+
opacity={0.06}
|
|
319
|
+
rx={4}
|
|
320
|
+
pointerEvents="none"
|
|
321
|
+
/>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Line / area / dot charts → vertical crosshair through the point.
|
|
326
|
+
const px = isBandScale
|
|
327
|
+
? ((xScale as ScaleBand<string>)(String(xv)) ?? 0) +
|
|
328
|
+
(xScale as ScaleBand<string>).bandwidth() / 2
|
|
329
|
+
: (xScale as (v: number) => number)(xv as number);
|
|
330
|
+
return (
|
|
331
|
+
<line
|
|
332
|
+
x1={px}
|
|
333
|
+
x2={px}
|
|
334
|
+
y1={0}
|
|
335
|
+
y2={height}
|
|
336
|
+
{...stylex.props(styles.crosshair)}
|
|
337
|
+
pointerEvents="none"
|
|
338
|
+
/>
|
|
339
|
+
);
|
|
340
|
+
}, [
|
|
341
|
+
hoverIndicator,
|
|
342
|
+
hoveredIndex,
|
|
343
|
+
series,
|
|
344
|
+
xScale,
|
|
345
|
+
data,
|
|
346
|
+
xKey,
|
|
347
|
+
width,
|
|
348
|
+
height,
|
|
349
|
+
margin.top,
|
|
350
|
+
]);
|
|
351
|
+
|
|
352
|
+
// ─── Render ────────────────────────────────────────────────────────────
|
|
353
|
+
if (typeof document === 'undefined') {
|
|
354
|
+
// SSR: no DOM portal target; band highlight + dots still render in SVG.
|
|
355
|
+
return (
|
|
356
|
+
<>
|
|
357
|
+
{hoverIndicatorElement}
|
|
358
|
+
{dots}
|
|
359
|
+
</>
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const cardContent =
|
|
364
|
+
hoveredIndex == null ? null : render ? (
|
|
365
|
+
render(xValue, seriesValues)
|
|
366
|
+
) : (
|
|
367
|
+
<DefaultTooltipContent xValue={xValue} rows={seriesValues} />
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
return (
|
|
371
|
+
<>
|
|
372
|
+
{hoverIndicatorElement}
|
|
373
|
+
{dots}
|
|
374
|
+
{createPortal(
|
|
375
|
+
<div ref={cardRef} {...stylex.props(styles.card)}>
|
|
376
|
+
{cardContent}
|
|
377
|
+
</div>,
|
|
378
|
+
document.body,
|
|
379
|
+
)}
|
|
380
|
+
</>
|
|
381
|
+
);
|
|
382
|
+
}
|
|
@@ -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: 'ChartV2',
|
|
7
|
+
displayName: 'Chart V2',
|
|
8
|
+
group: 'ChartV2',
|
|
9
|
+
category: 'Data Visualization',
|
|
10
|
+
|
|
11
|
+
usage: {
|
|
12
|
+
description: '',
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
props: [],
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {createContext, useContext} from 'react';
|
|
4
|
+
import type {ChartV2Context} from './types';
|
|
5
|
+
|
|
6
|
+
const Ctx = createContext<ChartV2Context | null>(null);
|
|
7
|
+
export const ChartV2Provider = Ctx.Provider;
|
|
8
|
+
|
|
9
|
+
export function useChartV2(): ChartV2Context {
|
|
10
|
+
const ctx = useContext(Ctx);
|
|
11
|
+
if (!ctx) {
|
|
12
|
+
throw new Error('Must be used inside <Chart>');
|
|
13
|
+
}
|
|
14
|
+
return ctx;
|
|
15
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
export {Chart, type ChartProps} from './Chart';
|
|
4
|
+
export {ChartAxis, type ChartAxisProps} from './ChartAxis';
|
|
5
|
+
export {ChartGrid, type ChartGridProps} from './ChartGrid';
|
|
6
|
+
export {
|
|
7
|
+
ChartLegend,
|
|
8
|
+
type ChartLegendProps,
|
|
9
|
+
type LegendPosition,
|
|
10
|
+
type LegendAlignment,
|
|
11
|
+
} from './ChartLegend';
|
|
12
|
+
export {type LegendItem} from './legend';
|
|
13
|
+
export {
|
|
14
|
+
ChartSwatch,
|
|
15
|
+
swatchVariantForType,
|
|
16
|
+
type ChartSwatchProps,
|
|
17
|
+
type ChartSwatchVariant,
|
|
18
|
+
} from './ChartSwatch';
|
|
19
|
+
export {
|
|
20
|
+
ChartTooltip,
|
|
21
|
+
type ChartTooltipProps,
|
|
22
|
+
type ChartTooltipPlacement,
|
|
23
|
+
} from './ChartTooltip';
|
|
24
|
+
export {type TooltipSeriesValue} from './tooltip';
|
|
25
|
+
export {
|
|
26
|
+
bar,
|
|
27
|
+
line,
|
|
28
|
+
dot,
|
|
29
|
+
area,
|
|
30
|
+
band,
|
|
31
|
+
candlestick,
|
|
32
|
+
errorBar,
|
|
33
|
+
referenceLine,
|
|
34
|
+
dotGL,
|
|
35
|
+
dotGLInteractive,
|
|
36
|
+
heatmapGL,
|
|
37
|
+
streamGL,
|
|
38
|
+
} from './marks';
|
|
39
|
+
export type {
|
|
40
|
+
BarOptions,
|
|
41
|
+
LineOptions,
|
|
42
|
+
DotOptions,
|
|
43
|
+
AreaOptions,
|
|
44
|
+
BandOptions,
|
|
45
|
+
CandlestickOptions,
|
|
46
|
+
ErrorBarOptions,
|
|
47
|
+
ReferenceLineOptions,
|
|
48
|
+
DotGLOptions,
|
|
49
|
+
DotGLInteractiveOptions,
|
|
50
|
+
HeatmapGLOptions,
|
|
51
|
+
StreamGLOptions,
|
|
52
|
+
StreamGLHandle,
|
|
53
|
+
} from './marks';
|
|
54
|
+
export {useChartV2} from './ChartV2Context';
|
|
55
|
+
export type {
|
|
56
|
+
SeriesDef,
|
|
57
|
+
ChartV2Context,
|
|
58
|
+
ChartPointerEvent,
|
|
59
|
+
ResolvedPoint,
|
|
60
|
+
ResolvedPositions,
|
|
61
|
+
SeriesContext,
|
|
62
|
+
} from './types';
|