@chipmobilesdk/rn-chart 0.3.0 → 0.5.0
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 +129 -0
- package/README.md +45 -3
- package/lib/commonjs/a11y/summary.js +190 -0
- package/lib/commonjs/a11y/summary.js.map +1 -0
- package/lib/commonjs/contract/datasource.js +64 -0
- package/lib/commonjs/contract/datasource.js.map +1 -0
- package/lib/commonjs/contract/distribution.js +45 -0
- package/lib/commonjs/contract/distribution.js.map +1 -0
- package/lib/commonjs/contract/errors.js +88 -0
- package/lib/commonjs/contract/errors.js.map +1 -0
- package/lib/commonjs/contract/format.js +133 -0
- package/lib/commonjs/contract/format.js.map +1 -0
- package/lib/commonjs/contract/interaction.js +24 -0
- package/lib/commonjs/contract/interaction.js.map +1 -0
- package/lib/commonjs/contract/marker.js +55 -0
- package/lib/commonjs/contract/marker.js.map +1 -0
- package/lib/commonjs/contract/props.js +6 -0
- package/lib/commonjs/contract/props.js.map +1 -0
- package/lib/commonjs/contract/state.js +68 -0
- package/lib/commonjs/contract/state.js.map +1 -0
- package/lib/commonjs/contract/strings.js +54 -0
- package/lib/commonjs/contract/strings.js.map +1 -0
- package/lib/commonjs/contract/theme.js +116 -0
- package/lib/commonjs/contract/theme.js.map +1 -0
- package/lib/commonjs/contract/value.js +112 -0
- package/lib/commonjs/contract/value.js.map +1 -0
- package/lib/commonjs/geometry/bar.js +257 -0
- package/lib/commonjs/geometry/bar.js.map +1 -0
- package/lib/commonjs/geometry/distribution.js +197 -0
- package/lib/commonjs/geometry/distribution.js.map +1 -0
- package/lib/commonjs/geometry/heatmap.js +186 -0
- package/lib/commonjs/geometry/heatmap.js.map +1 -0
- package/lib/commonjs/geometry/hitTest.js +117 -0
- package/lib/commonjs/geometry/hitTest.js.map +1 -0
- package/lib/commonjs/geometry/layout.js +134 -0
- package/lib/commonjs/geometry/layout.js.map +1 -0
- package/lib/commonjs/geometry/markers.js +59 -0
- package/lib/commonjs/geometry/markers.js.map +1 -0
- package/lib/commonjs/geometry/path.js +166 -0
- package/lib/commonjs/geometry/path.js.map +1 -0
- package/lib/commonjs/geometry/progress.js +203 -0
- package/lib/commonjs/geometry/progress.js.map +1 -0
- package/lib/commonjs/geometry/scale.js +127 -0
- package/lib/commonjs/geometry/scale.js.map +1 -0
- package/lib/commonjs/geometry/ticks.js +120 -0
- package/lib/commonjs/geometry/ticks.js.map +1 -0
- package/lib/commonjs/geometry/timeSeries.js +157 -0
- package/lib/commonjs/geometry/timeSeries.js.map +1 -0
- package/lib/commonjs/geometry/types.js +43 -0
- package/lib/commonjs/geometry/types.js.map +1 -0
- package/lib/commonjs/index.js +284 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/react/ChartBoundary.js +82 -0
- package/lib/commonjs/react/ChartBoundary.js.map +1 -0
- package/lib/commonjs/react/ChartFrame.js +270 -0
- package/lib/commonjs/react/ChartFrame.js.map +1 -0
- package/lib/commonjs/react/ChartLegend.js +242 -0
- package/lib/commonjs/react/ChartLegend.js.map +1 -0
- package/lib/commonjs/react/ChartPlot.js +62 -0
- package/lib/commonjs/react/ChartPlot.js.map +1 -0
- package/lib/commonjs/react/ChartStateOverlay.js +89 -0
- package/lib/commonjs/react/ChartStateOverlay.js.map +1 -0
- package/lib/commonjs/react/ChartThemeProvider.js +51 -0
- package/lib/commonjs/react/ChartThemeProvider.js.map +1 -0
- package/lib/commonjs/react/charts.js +108 -0
- package/lib/commonjs/react/charts.js.map +1 -0
- package/lib/commonjs/react/pointEvent.js +35 -0
- package/lib/commonjs/react/pointEvent.js.map +1 -0
- package/lib/commonjs/react/useChartA11y.js +97 -0
- package/lib/commonjs/react/useChartA11y.js.map +1 -0
- package/lib/commonjs/react/useChartFormatters.js +66 -0
- package/lib/commonjs/react/useChartFormatters.js.map +1 -0
- package/lib/commonjs/react/useChartLayout.js +100 -0
- package/lib/commonjs/react/useChartLayout.js.map +1 -0
- package/lib/commonjs/react/useChartSelection.js +131 -0
- package/lib/commonjs/react/useChartSelection.js.map +1 -0
- package/lib/commonjs/react/useChartStatus.js +74 -0
- package/lib/commonjs/react/useChartStatus.js.map +1 -0
- package/lib/commonjs/render/Axis.js +88 -0
- package/lib/commonjs/render/Axis.js.map +1 -0
- package/lib/commonjs/render/Marks.js +184 -0
- package/lib/commonjs/render/Marks.js.map +1 -0
- package/lib/commonjs/validation/budgets.js +106 -0
- package/lib/commonjs/validation/budgets.js.map +1 -0
- package/lib/commonjs/validation/validateDatasource.js +189 -0
- package/lib/commonjs/validation/validateDatasource.js.map +1 -0
- package/lib/module/a11y/summary.js +184 -0
- package/lib/module/a11y/summary.js.map +1 -0
- package/lib/module/contract/datasource.js +57 -0
- package/lib/module/contract/datasource.js.map +1 -0
- package/lib/module/contract/distribution.js +40 -0
- package/lib/module/contract/distribution.js.map +1 -0
- package/lib/module/contract/errors.js +80 -0
- package/lib/module/contract/errors.js.map +1 -0
- package/lib/module/contract/format.js +123 -0
- package/lib/module/contract/format.js.map +1 -0
- package/lib/module/contract/interaction.js +20 -0
- package/lib/module/contract/interaction.js.map +1 -0
- package/lib/module/contract/marker.js +49 -0
- package/lib/module/contract/marker.js.map +1 -0
- package/lib/module/contract/props.js +4 -0
- package/lib/module/contract/props.js.map +1 -0
- package/lib/module/contract/state.js +61 -0
- package/lib/module/contract/state.js.map +1 -0
- package/lib/module/contract/strings.js +49 -0
- package/lib/module/contract/strings.js.map +1 -0
- package/lib/module/contract/theme.js +109 -0
- package/lib/module/contract/theme.js.map +1 -0
- package/lib/module/contract/value.js +101 -0
- package/lib/module/contract/value.js.map +1 -0
- package/lib/module/geometry/bar.js +253 -0
- package/lib/module/geometry/bar.js.map +1 -0
- package/lib/module/geometry/distribution.js +193 -0
- package/lib/module/geometry/distribution.js.map +1 -0
- package/lib/module/geometry/heatmap.js +182 -0
- package/lib/module/geometry/heatmap.js.map +1 -0
- package/lib/module/geometry/hitTest.js +110 -0
- package/lib/module/geometry/hitTest.js.map +1 -0
- package/lib/module/geometry/layout.js +122 -0
- package/lib/module/geometry/layout.js.map +1 -0
- package/lib/module/geometry/markers.js +53 -0
- package/lib/module/geometry/markers.js.map +1 -0
- package/lib/module/geometry/path.js +157 -0
- package/lib/module/geometry/path.js.map +1 -0
- package/lib/module/geometry/progress.js +199 -0
- package/lib/module/geometry/progress.js.map +1 -0
- package/lib/module/geometry/scale.js +119 -0
- package/lib/module/geometry/scale.js.map +1 -0
- package/lib/module/geometry/ticks.js +112 -0
- package/lib/module/geometry/ticks.js.map +1 -0
- package/lib/module/geometry/timeSeries.js +153 -0
- package/lib/module/geometry/timeSeries.js.map +1 -0
- package/lib/module/geometry/types.js +39 -0
- package/lib/module/geometry/types.js.map +1 -0
- package/lib/module/index.js +85 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/react/ChartBoundary.js +75 -0
- package/lib/module/react/ChartBoundary.js.map +1 -0
- package/lib/module/react/ChartFrame.js +263 -0
- package/lib/module/react/ChartFrame.js.map +1 -0
- package/lib/module/react/ChartLegend.js +234 -0
- package/lib/module/react/ChartLegend.js.map +1 -0
- package/lib/module/react/ChartPlot.js +56 -0
- package/lib/module/react/ChartPlot.js.map +1 -0
- package/lib/module/react/ChartStateOverlay.js +82 -0
- package/lib/module/react/ChartStateOverlay.js.map +1 -0
- package/lib/module/react/ChartThemeProvider.js +44 -0
- package/lib/module/react/ChartThemeProvider.js.map +1 -0
- package/lib/module/react/charts.js +102 -0
- package/lib/module/react/charts.js.map +1 -0
- package/lib/module/react/pointEvent.js +30 -0
- package/lib/module/react/pointEvent.js.map +1 -0
- package/lib/module/react/useChartA11y.js +92 -0
- package/lib/module/react/useChartA11y.js.map +1 -0
- package/lib/module/react/useChartFormatters.js +61 -0
- package/lib/module/react/useChartFormatters.js.map +1 -0
- package/lib/module/react/useChartLayout.js +95 -0
- package/lib/module/react/useChartLayout.js.map +1 -0
- package/lib/module/react/useChartSelection.js +125 -0
- package/lib/module/react/useChartSelection.js.map +1 -0
- package/lib/module/react/useChartStatus.js +69 -0
- package/lib/module/react/useChartStatus.js.map +1 -0
- package/lib/module/render/Axis.js +80 -0
- package/lib/module/render/Axis.js.map +1 -0
- package/lib/module/render/Marks.js +173 -0
- package/lib/module/render/Marks.js.map +1 -0
- package/lib/module/validation/budgets.js +97 -0
- package/lib/module/validation/budgets.js.map +1 -0
- package/lib/module/validation/validateDatasource.js +184 -0
- package/lib/module/validation/validateDatasource.js.map +1 -0
- package/lib/typescript/commonjs/a11y/summary.d.ts +38 -0
- package/lib/typescript/commonjs/a11y/summary.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/datasource.d.ts +94 -0
- package/lib/typescript/commonjs/contract/datasource.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/distribution.d.ts +17 -0
- package/lib/typescript/commonjs/contract/distribution.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/errors.d.ts +53 -0
- package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/format.d.ts +63 -0
- package/lib/typescript/commonjs/contract/format.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/marker.d.ts +39 -0
- package/lib/typescript/commonjs/contract/marker.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/props.d.ts +58 -0
- package/lib/typescript/commonjs/contract/props.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/state.d.ts +45 -0
- package/lib/typescript/commonjs/contract/state.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/strings.d.ts +39 -0
- package/lib/typescript/commonjs/contract/strings.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/theme.d.ts +85 -0
- package/lib/typescript/commonjs/contract/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/value.d.ts +69 -0
- package/lib/typescript/commonjs/contract/value.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/bar.d.ts +18 -0
- package/lib/typescript/commonjs/geometry/bar.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/distribution.d.ts +23 -0
- package/lib/typescript/commonjs/geometry/distribution.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/heatmap.d.ts +24 -0
- package/lib/typescript/commonjs/geometry/heatmap.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/hitTest.d.ts +68 -0
- package/lib/typescript/commonjs/geometry/hitTest.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/layout.d.ts +67 -0
- package/lib/typescript/commonjs/geometry/layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/markers.d.ts +29 -0
- package/lib/typescript/commonjs/geometry/markers.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/path.d.ts +66 -0
- package/lib/typescript/commonjs/geometry/path.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/progress.d.ts +17 -0
- package/lib/typescript/commonjs/geometry/progress.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/scale.d.ts +55 -0
- package/lib/typescript/commonjs/geometry/scale.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/ticks.d.ts +48 -0
- package/lib/typescript/commonjs/geometry/ticks.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/timeSeries.d.ts +20 -0
- package/lib/typescript/commonjs/geometry/timeSeries.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/types.d.ts +91 -0
- package/lib/typescript/commonjs/geometry/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +47 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/react/ChartBoundary.d.ts +47 -0
- package/lib/typescript/commonjs/react/ChartBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartFrame.d.ts +31 -0
- package/lib/typescript/commonjs/react/ChartFrame.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartLegend.d.ts +31 -0
- package/lib/typescript/commonjs/react/ChartLegend.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartPlot.d.ts +19 -0
- package/lib/typescript/commonjs/react/ChartPlot.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartStateOverlay.d.ts +25 -0
- package/lib/typescript/commonjs/react/ChartStateOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartThemeProvider.d.ts +21 -0
- package/lib/typescript/commonjs/react/ChartThemeProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/charts.d.ts +51 -0
- package/lib/typescript/commonjs/react/charts.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/pointEvent.d.ts +13 -0
- package/lib/typescript/commonjs/react/pointEvent.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartA11y.d.ts +37 -0
- package/lib/typescript/commonjs/react/useChartA11y.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartFormatters.d.ts +21 -0
- package/lib/typescript/commonjs/react/useChartFormatters.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartLayout.d.ts +27 -0
- package/lib/typescript/commonjs/react/useChartLayout.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartSelection.d.ts +52 -0
- package/lib/typescript/commonjs/react/useChartSelection.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartStatus.d.ts +22 -0
- package/lib/typescript/commonjs/react/useChartStatus.d.ts.map +1 -0
- package/lib/typescript/commonjs/render/Axis.d.ts +31 -0
- package/lib/typescript/commonjs/render/Axis.d.ts.map +1 -0
- package/lib/typescript/commonjs/render/Marks.d.ts +44 -0
- package/lib/typescript/commonjs/render/Marks.d.ts.map +1 -0
- package/lib/typescript/commonjs/validation/budgets.d.ts +24 -0
- package/lib/typescript/commonjs/validation/budgets.d.ts.map +1 -0
- package/lib/typescript/commonjs/validation/validateDatasource.d.ts +26 -0
- package/lib/typescript/commonjs/validation/validateDatasource.d.ts.map +1 -0
- package/lib/typescript/module/a11y/summary.d.ts +38 -0
- package/lib/typescript/module/a11y/summary.d.ts.map +1 -0
- package/lib/typescript/module/contract/datasource.d.ts +94 -0
- package/lib/typescript/module/contract/datasource.d.ts.map +1 -0
- package/lib/typescript/module/contract/distribution.d.ts +17 -0
- package/lib/typescript/module/contract/distribution.d.ts.map +1 -0
- package/lib/typescript/module/contract/errors.d.ts +53 -0
- package/lib/typescript/module/contract/errors.d.ts.map +1 -0
- package/lib/typescript/module/contract/format.d.ts +63 -0
- package/lib/typescript/module/contract/format.d.ts.map +1 -0
- package/lib/typescript/module/contract/interaction.d.ts +53 -0
- package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/module/contract/marker.d.ts +39 -0
- package/lib/typescript/module/contract/marker.d.ts.map +1 -0
- package/lib/typescript/module/contract/props.d.ts +58 -0
- package/lib/typescript/module/contract/props.d.ts.map +1 -0
- package/lib/typescript/module/contract/state.d.ts +45 -0
- package/lib/typescript/module/contract/state.d.ts.map +1 -0
- package/lib/typescript/module/contract/strings.d.ts +39 -0
- package/lib/typescript/module/contract/strings.d.ts.map +1 -0
- package/lib/typescript/module/contract/theme.d.ts +85 -0
- package/lib/typescript/module/contract/theme.d.ts.map +1 -0
- package/lib/typescript/module/contract/value.d.ts +69 -0
- package/lib/typescript/module/contract/value.d.ts.map +1 -0
- package/lib/typescript/module/geometry/bar.d.ts +18 -0
- package/lib/typescript/module/geometry/bar.d.ts.map +1 -0
- package/lib/typescript/module/geometry/distribution.d.ts +23 -0
- package/lib/typescript/module/geometry/distribution.d.ts.map +1 -0
- package/lib/typescript/module/geometry/heatmap.d.ts +24 -0
- package/lib/typescript/module/geometry/heatmap.d.ts.map +1 -0
- package/lib/typescript/module/geometry/hitTest.d.ts +68 -0
- package/lib/typescript/module/geometry/hitTest.d.ts.map +1 -0
- package/lib/typescript/module/geometry/layout.d.ts +67 -0
- package/lib/typescript/module/geometry/layout.d.ts.map +1 -0
- package/lib/typescript/module/geometry/markers.d.ts +29 -0
- package/lib/typescript/module/geometry/markers.d.ts.map +1 -0
- package/lib/typescript/module/geometry/path.d.ts +66 -0
- package/lib/typescript/module/geometry/path.d.ts.map +1 -0
- package/lib/typescript/module/geometry/progress.d.ts +17 -0
- package/lib/typescript/module/geometry/progress.d.ts.map +1 -0
- package/lib/typescript/module/geometry/scale.d.ts +55 -0
- package/lib/typescript/module/geometry/scale.d.ts.map +1 -0
- package/lib/typescript/module/geometry/ticks.d.ts +48 -0
- package/lib/typescript/module/geometry/ticks.d.ts.map +1 -0
- package/lib/typescript/module/geometry/timeSeries.d.ts +20 -0
- package/lib/typescript/module/geometry/timeSeries.d.ts.map +1 -0
- package/lib/typescript/module/geometry/types.d.ts +91 -0
- package/lib/typescript/module/geometry/types.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +47 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/react/ChartBoundary.d.ts +47 -0
- package/lib/typescript/module/react/ChartBoundary.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartFrame.d.ts +31 -0
- package/lib/typescript/module/react/ChartFrame.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartLegend.d.ts +31 -0
- package/lib/typescript/module/react/ChartLegend.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartPlot.d.ts +19 -0
- package/lib/typescript/module/react/ChartPlot.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartStateOverlay.d.ts +25 -0
- package/lib/typescript/module/react/ChartStateOverlay.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartThemeProvider.d.ts +21 -0
- package/lib/typescript/module/react/ChartThemeProvider.d.ts.map +1 -0
- package/lib/typescript/module/react/charts.d.ts +51 -0
- package/lib/typescript/module/react/charts.d.ts.map +1 -0
- package/lib/typescript/module/react/pointEvent.d.ts +13 -0
- package/lib/typescript/module/react/pointEvent.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartA11y.d.ts +37 -0
- package/lib/typescript/module/react/useChartA11y.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartFormatters.d.ts +21 -0
- package/lib/typescript/module/react/useChartFormatters.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartLayout.d.ts +27 -0
- package/lib/typescript/module/react/useChartLayout.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartSelection.d.ts +52 -0
- package/lib/typescript/module/react/useChartSelection.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartStatus.d.ts +22 -0
- package/lib/typescript/module/react/useChartStatus.d.ts.map +1 -0
- package/lib/typescript/module/render/Axis.d.ts +31 -0
- package/lib/typescript/module/render/Axis.d.ts.map +1 -0
- package/lib/typescript/module/render/Marks.d.ts +44 -0
- package/lib/typescript/module/render/Marks.d.ts.map +1 -0
- package/lib/typescript/module/validation/budgets.d.ts +24 -0
- package/lib/typescript/module/validation/budgets.d.ts.map +1 -0
- package/lib/typescript/module/validation/validateDatasource.d.ts +26 -0
- package/lib/typescript/module/validation/validateDatasource.d.ts.map +1 -0
- package/package.json +40 -15
- package/skills/sdk-rn-chart/SKILL.md +49 -14
- package/src/a11y/summary.ts +34 -15
- package/src/contract/distribution.ts +44 -0
- package/src/contract/errors.ts +6 -0
- package/src/contract/interaction.ts +2 -2
- package/src/contract/strings.ts +2 -0
- package/src/geometry/bar.ts +27 -16
- package/src/geometry/distribution.ts +11 -6
- package/src/geometry/heatmap.ts +34 -17
- package/src/geometry/hitTest.ts +35 -0
- package/src/geometry/progress.ts +0 -1
- package/src/geometry/ticks.ts +0 -13
- package/src/geometry/timeSeries.ts +7 -2
- package/src/geometry/types.ts +11 -0
- package/src/index.ts +4 -1
- package/src/react/ChartFrame.tsx +126 -373
- package/src/react/ChartLegend.tsx +60 -3
- package/src/react/ChartPlot.tsx +57 -0
- package/src/react/ChartStateOverlay.tsx +94 -0
- package/src/react/charts.tsx +27 -12
- package/src/react/pointEvent.ts +40 -0
- package/src/react/useChartA11y.ts +113 -0
- package/src/react/useChartFormatters.ts +105 -0
- package/src/react/useChartLayout.ts +5 -2
- package/src/react/useChartSelection.ts +77 -40
- package/src/react/useChartStatus.ts +85 -0
- package/src/render/Axis.tsx +26 -22
- package/src/render/Marks.tsx +2 -9
- package/src/validation/budgets.ts +6 -4
- package/src/validation/validateDatasource.ts +38 -14
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Selection ownership: uncontrolled by default, controlled when the app
|
|
5
|
+
* supplies a value (FR-054a).
|
|
6
|
+
*
|
|
7
|
+
* Three properties matter and all are load-bearing:
|
|
8
|
+
*
|
|
9
|
+
* - The selection is **resolved against the current datasource on every
|
|
10
|
+
* render** rather than stored resolved. A reference to a point that no
|
|
11
|
+
* longer exists therefore draws nothing, in either mode (FR-054).
|
|
12
|
+
* - Selection state lives outside the geometry memo, so highlighting repaints
|
|
13
|
+
* the highlight without recomputing scales or path strings (FR-073).
|
|
14
|
+
* - `select` and `toggle` keep one identity for the life of the chart. They
|
|
15
|
+
* read the app's callbacks through a ref, so an inline callback does not
|
|
16
|
+
* make every render look like a change (CHT-08).
|
|
17
|
+
*/
|
|
18
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
+
import { sameSelection } from "../contract/interaction.js";
|
|
20
|
+
import { findRegion } from "../geometry/hitTest.js";
|
|
21
|
+
export function useChartSelection(args) {
|
|
22
|
+
const isControlled = args.controlled !== undefined;
|
|
23
|
+
const [internal, setInternal] = useState(null);
|
|
24
|
+
const selection = isControlled ? args.controlled ?? null : internal;
|
|
25
|
+
|
|
26
|
+
// Resolve fresh every render. A stale reference resolves to `undefined` and
|
|
27
|
+
// simply is not drawn.
|
|
28
|
+
const resolved = selection && !args.interactionSuppressed ? findRegion(args.hitRegions, selection.seriesId, selection.pointId) : undefined;
|
|
29
|
+
const latest = useRef({
|
|
30
|
+
args,
|
|
31
|
+
selection,
|
|
32
|
+
isControlled
|
|
33
|
+
});
|
|
34
|
+
latest.current = {
|
|
35
|
+
args,
|
|
36
|
+
selection,
|
|
37
|
+
isControlled
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Tell a controlling app when its selection stopped resolving, rather than
|
|
41
|
+
// silently ignoring it. Uncontrolled selections are cleared instead. Keyed
|
|
42
|
+
// on what the selection is, not on object identity, so an app passing
|
|
43
|
+
// `selection={{…}}` inline does not re-run this every render.
|
|
44
|
+
const selectionKey = selection ? `${selection.seriesId}:${selection.pointId ?? ''}` : null;
|
|
45
|
+
const unresolved = selectionKey !== null && !resolved && !args.interactionSuppressed && args.geometryReady;
|
|
46
|
+
const reportedRef = useRef(null);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!unresolved) {
|
|
49
|
+
reportedRef.current = null;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (reportedRef.current === selectionKey) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
reportedRef.current = selectionKey;
|
|
56
|
+
const current = latest.current;
|
|
57
|
+
if (current.isControlled) {
|
|
58
|
+
if (current.selection) {
|
|
59
|
+
current.args.onSelectionUnresolvable?.(current.selection);
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
setInternal(null);
|
|
63
|
+
}
|
|
64
|
+
}, [unresolved, selectionKey]);
|
|
65
|
+
const select = useCallback((ref, event, options) => {
|
|
66
|
+
const current = latest.current;
|
|
67
|
+
if (current.args.interactionSuppressed) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Decided once, then used for the state and for the report: the app
|
|
71
|
+
// used to be told a point was selected at the very moment the chart
|
|
72
|
+
// dropped its highlight (CHT-06).
|
|
73
|
+
const next = options?.toggle !== false && sameSelection(current.selection, ref) ? null : ref;
|
|
74
|
+
if (!current.isControlled) {
|
|
75
|
+
setInternal(next);
|
|
76
|
+
}
|
|
77
|
+
current.args.onSelectionChange?.(next, next ? event : null);
|
|
78
|
+
}, []);
|
|
79
|
+
return {
|
|
80
|
+
resolved,
|
|
81
|
+
selection,
|
|
82
|
+
select
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Cannot occur in a series id that came from JSON or a database key. */
|
|
86
|
+
const SEPARATOR = '\u0000';
|
|
87
|
+
export function useSeriesVisibility(args) {
|
|
88
|
+
const isControlled = args.controlled !== undefined;
|
|
89
|
+
const [internal, setInternal] = useState(args.initiallyHidden);
|
|
90
|
+
const hiddenList = isControlled ? args.controlled ?? [] : internal;
|
|
91
|
+
const hiddenKey = [...hiddenList].sort((a, b) => a.localeCompare(b)).join(SEPARATOR);
|
|
92
|
+
const hidden = useMemo(() => new Set(hiddenKey === '' ? [] : hiddenKey.split(SEPARATOR)), [hiddenKey]);
|
|
93
|
+
const latest = useRef({
|
|
94
|
+
args,
|
|
95
|
+
hidden,
|
|
96
|
+
isControlled
|
|
97
|
+
});
|
|
98
|
+
latest.current = {
|
|
99
|
+
args,
|
|
100
|
+
hidden,
|
|
101
|
+
isControlled
|
|
102
|
+
};
|
|
103
|
+
const toggle = useCallback((seriesId, metadata) => {
|
|
104
|
+
const current = latest.current;
|
|
105
|
+
if (!current.args.enabled) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const willBeVisible = current.hidden.has(seriesId);
|
|
109
|
+
if (!current.isControlled) {
|
|
110
|
+
setInternal(prev => prev.includes(seriesId) ? prev.filter(id => id !== seriesId) : [...prev, seriesId]);
|
|
111
|
+
}
|
|
112
|
+
current.args.onVisibilityChange?.({
|
|
113
|
+
type: 'visibilityChange',
|
|
114
|
+
seriesId,
|
|
115
|
+
visible: willBeVisible,
|
|
116
|
+
metadata: metadata
|
|
117
|
+
});
|
|
118
|
+
}, []);
|
|
119
|
+
return {
|
|
120
|
+
hidden,
|
|
121
|
+
toggle,
|
|
122
|
+
enabled: args.enabled
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=useChartSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","sameSelection","findRegion","useChartSelection","args","isControlled","controlled","undefined","internal","setInternal","selection","resolved","interactionSuppressed","hitRegions","seriesId","pointId","latest","current","selectionKey","unresolved","geometryReady","reportedRef","onSelectionUnresolvable","select","ref","event","options","next","toggle","onSelectionChange","SEPARATOR","useSeriesVisibility","initiallyHidden","hiddenList","hiddenKey","sort","a","b","localeCompare","join","hidden","Set","split","metadata","enabled","willBeVisible","has","prev","includes","filter","id","onVisibilityChange","type","visible"],"sourceRoot":"../../../src","sources":["react/useChartSelection.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAOzE,SAASC,aAAa,QAAQ,4BAAyB;AACvD,SAASC,UAAU,QAAwB,wBAAqB;AA4ChE,OAAO,SAASC,iBAAiBA,CAAIC,IAA8B,EAAwB;EAC1F,MAAMC,YAAY,GAAGD,IAAI,CAACE,UAAU,KAAKC,SAAS;EAClD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGT,QAAQ,CAAsB,IAAI,CAAC;EAEnE,MAAMU,SAAS,GAAGL,YAAY,GAAID,IAAI,CAACE,UAAU,IAAI,IAAI,GAAIE,QAAQ;;EAErE;EACA;EACA,MAAMG,QAAQ,GACbD,SAAS,IAAI,CAACN,IAAI,CAACQ,qBAAqB,GACrCV,UAAU,CAACE,IAAI,CAACS,UAAU,EAAEH,SAAS,CAACI,QAAQ,EAAEJ,SAAS,CAACK,OAAO,CAAC,GAClER,SAAS;EAEb,MAAMS,MAAM,GAAGjB,MAAM,CAAC;IAAEK,IAAI;IAAEM,SAAS;IAAEL;EAAa,CAAC,CAAC;EACxDW,MAAM,CAACC,OAAO,GAAG;IAAEb,IAAI;IAAEM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IAC9B,IAAI,CAACA,OAAO,CAACb,IAAI,CAACwC,OAAO,EAAE;MAC1B;IACD;IACA,MAAMC,aAAa,GAAG5B,OAAO,CAACuB,MAAM,CAACM,GAAG,CAAChC,QAAQ,CAAC;IAElD,IAAI,CAACG,OAAO,CAACZ,YAAY,EAAE;MAC1BI,WAAW,CAACsC,IAAI,IACfA,IAAI,CAACC,QAAQ,CAAClC,QAAQ,CAAC,GAAGiC,IAAI,CAACE,MAAM,CAACC,EAAE,IAAIA,EAAE,KAAKpC,QAAQ,CAAC,GAAG,CAAC,GAAGiC,IAAI,EAAEjC,QAAQ,CAClF,CAAC;IACF;IAEAG,OAAO,CAACb,IAAI,CAAC+C,kBAAkB,GAAG;MACjCC,IAAI,EAAE,kBAAkB;MACxBtC,QAAQ;MACRuC,OAAO,EAAER,aAAa;MACtBF,QAAQ,EAAEA;IACX,CAAC,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEH,MAAM;IAAEZ,MAAM;IAAEgB,OAAO,EAAExC,IAAI,CAACwC;EAAQ,CAAC;AACjD","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What state the chart is in: validation, the app's declared status, and the
|
|
5
|
+
* one report a validation failure gets.
|
|
6
|
+
*/
|
|
7
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
8
|
+
import { chartError } from "../contract/errors.js";
|
|
9
|
+
import { resolveStatus } from "../contract/state.js";
|
|
10
|
+
import { releaseBudgetWarning, warnIfOverBudget } from "../validation/budgets.js";
|
|
11
|
+
import { validateDatasource } from "../validation/validateDatasource.js";
|
|
12
|
+
export function useChartStatus(args) {
|
|
13
|
+
const {
|
|
14
|
+
datasource,
|
|
15
|
+
family,
|
|
16
|
+
chartId,
|
|
17
|
+
instanceKey,
|
|
18
|
+
distributionValues
|
|
19
|
+
} = args;
|
|
20
|
+
const validation = useMemo(() => validateDatasource(datasource, family, chartId, distributionValues), [datasource, family, chartId, distributionValues]);
|
|
21
|
+
|
|
22
|
+
// Warn once per chart instance, dev only, and release the key on unmount so
|
|
23
|
+
// a remount warns again. An effect, not a memo: a warning is a side effect,
|
|
24
|
+
// and React may run a memo's function more than once or discard its result.
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
warnIfOverBudget(datasource, family, instanceKey);
|
|
27
|
+
}, [datasource, family, instanceKey]);
|
|
28
|
+
useEffect(() => () => releaseBudgetWarning(instanceKey), [instanceKey]);
|
|
29
|
+
const declaredError = args.declared === 'error' ? chartError('declared', 'declaredByApp', {
|
|
30
|
+
chartId,
|
|
31
|
+
family
|
|
32
|
+
}) : undefined;
|
|
33
|
+
const error = validation.error ?? declaredError;
|
|
34
|
+
const status = resolveStatus({
|
|
35
|
+
declared: args.declared,
|
|
36
|
+
isEmpty: validation.isEmpty,
|
|
37
|
+
isPartial: validation.isPartial,
|
|
38
|
+
error
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// A validation failure is reported through the same channel as a contained
|
|
42
|
+
// render exception, so consumers have one place to watch. `onFailure` is
|
|
43
|
+
// read through a ref: an inline callback would otherwise re-fire the report
|
|
44
|
+
// on every render.
|
|
45
|
+
const reportedRef = useRef(undefined);
|
|
46
|
+
const onFailureRef = useRef(args.onFailure);
|
|
47
|
+
onFailureRef.current = args.onFailure;
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!validation.error) {
|
|
50
|
+
reportedRef.current = undefined;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (reportedRef.current === validation.error.code) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
reportedRef.current = validation.error.code;
|
|
57
|
+
onFailureRef.current?.({
|
|
58
|
+
chartId: validation.error.chartId,
|
|
59
|
+
family: validation.error.family ?? family,
|
|
60
|
+
error: validation.error
|
|
61
|
+
});
|
|
62
|
+
}, [validation.error, family]);
|
|
63
|
+
return {
|
|
64
|
+
validation,
|
|
65
|
+
error,
|
|
66
|
+
status
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=useChartStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useRef","chartError","resolveStatus","releaseBudgetWarning","warnIfOverBudget","validateDatasource","useChartStatus","args","datasource","family","chartId","instanceKey","distributionValues","validation","declaredError","declared","undefined","error","status","isEmpty","isPartial","reportedRef","onFailureRef","onFailure","current","code"],"sourceRoot":"../../../src","sources":["react/useChartStatus.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAIlD,SAASC,UAAU,QAAmD,uBAAoB;AAC1F,SAASC,aAAa,QAAsD,sBAAmB;AAC/F,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,0BAAuB;AAC9E,SAASC,kBAAkB,QAA+B,qCAAkC;AAmB5F,OAAO,SAASC,cAAcA,CAAIC,IAA2B,EAAqB;EACjF,MAAM;IAAEC,UAAU;IAAEC,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAmB,CAAC,GAAGL,IAAI;EAE7E,MAAMM,UAAU,GAAGd,OAAO,CACzB,MAAMM,kBAAkB,CAACG,UAAU,EAAEC,MAAM,EAAEC,OAAO,EAAEE,kBAAkB,CAAC,EACzE,CAACJ,UAAU,EAAEC,MAAM,EAAEC,OAAO,EAAEE,kBAAkB,CACjD,CAAC;;EAED;EACA;EACA;EACAd,SAAS,CAAC,MAAM;IACfM,gBAAgB,CAACI,UAAU,EAAEC,MAAM,EAAEE,WAAW,CAAC;EAClD,CAAC,EAAE,CAACH,UAAU,EAAEC,MAAM,EAAEE,WAAW,CAAC,CAAC;EACrCb,SAAS,CAAC,MAAM,MAAMK,oBAAoB,CAACQ,WAAW,CAAC,EAAE,CAACA,WAAW,CAAC,CAAC;EAEvE,MAAMG,aAAa,GAClBP,IAAI,CAACQ,QAAQ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
|
4
|
+
* Axis and grid rendering. Private SVG adapter.
|
|
5
|
+
*
|
|
6
|
+
* Ticks arrive already thinned by `geometry/ticks.ts`, so nothing here decides
|
|
7
|
+
* what fits — this module only draws what the geometry chose.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { G, Line, Text as SvgText } from 'react-native-svg';
|
|
11
|
+
import { plotBottom, plotRight } from "../geometry/layout.js";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export function Grid({
|
|
14
|
+
plot,
|
|
15
|
+
yTicks,
|
|
16
|
+
theme
|
|
17
|
+
}) {
|
|
18
|
+
return /*#__PURE__*/_jsx(G, {
|
|
19
|
+
children: yTicks.map(tick => /*#__PURE__*/_jsx(Line, {
|
|
20
|
+
x1: plot.x,
|
|
21
|
+
y1: tick.position,
|
|
22
|
+
x2: plotRight(plot),
|
|
23
|
+
y2: tick.position,
|
|
24
|
+
stroke: theme.grid,
|
|
25
|
+
strokeWidth: 1
|
|
26
|
+
}, `grid-${tick.value}`))
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function XAxis({
|
|
30
|
+
plot,
|
|
31
|
+
ticks,
|
|
32
|
+
theme,
|
|
33
|
+
fontSize,
|
|
34
|
+
line = true
|
|
35
|
+
}) {
|
|
36
|
+
const baseline = plotBottom(plot);
|
|
37
|
+
return /*#__PURE__*/_jsxs(G, {
|
|
38
|
+
children: [line ? /*#__PURE__*/_jsx(Line, {
|
|
39
|
+
x1: plot.x,
|
|
40
|
+
y1: baseline,
|
|
41
|
+
x2: plotRight(plot),
|
|
42
|
+
y2: baseline,
|
|
43
|
+
stroke: theme.axis,
|
|
44
|
+
strokeWidth: 1
|
|
45
|
+
}) : null, ticks.map(tick => /*#__PURE__*/_jsx(SvgText, {
|
|
46
|
+
x: tick.position,
|
|
47
|
+
y: baseline + fontSize + 4,
|
|
48
|
+
fill: theme.typography.axisLabel.color,
|
|
49
|
+
fontSize: fontSize,
|
|
50
|
+
textAnchor: "middle",
|
|
51
|
+
children: tick.label
|
|
52
|
+
}, `x-${tick.position}-${tick.label}`))]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export function YAxis({
|
|
56
|
+
plot,
|
|
57
|
+
ticks,
|
|
58
|
+
theme,
|
|
59
|
+
fontSize,
|
|
60
|
+
line = true
|
|
61
|
+
}) {
|
|
62
|
+
return /*#__PURE__*/_jsxs(G, {
|
|
63
|
+
children: [line ? /*#__PURE__*/_jsx(Line, {
|
|
64
|
+
x1: plot.x,
|
|
65
|
+
y1: plot.y,
|
|
66
|
+
x2: plot.x,
|
|
67
|
+
y2: plotBottom(plot),
|
|
68
|
+
stroke: theme.axis,
|
|
69
|
+
strokeWidth: 1
|
|
70
|
+
}) : null, ticks.map(tick => /*#__PURE__*/_jsx(SvgText, {
|
|
71
|
+
x: plot.x - 6,
|
|
72
|
+
y: tick.position + fontSize / 3,
|
|
73
|
+
fill: theme.typography.axisLabel.color,
|
|
74
|
+
fontSize: fontSize,
|
|
75
|
+
textAnchor: "end",
|
|
76
|
+
children: tick.label
|
|
77
|
+
}, `y-${tick.position}-${tick.label}`))]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=Axis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","G","Line","Text","SvgText","plotBottom","plotRight","jsx","_jsx","jsxs","_jsxs","Grid","plot","yTicks","theme","children","map","tick","x1","x","y1","position","x2","y2","stroke","grid","strokeWidth","value","XAxis","ticks","fontSize","line","baseline","axis","y","fill","typography","axisLabel","color","textAnchor","label","YAxis"],"sourceRoot":"../../../src","sources":["render/Axis.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,CAAC,EAAEC,IAAI,EAAEC,IAAI,IAAIC,OAAO,QAAQ,kBAAkB;AAI3D,SAASC,UAAU,EAAEC,SAAS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|
+
*
|
|
6
|
+
* Everything here consumes plain data produced by `geometry/`. Swapping the
|
|
7
|
+
* drawing substrate means rewriting this directory and nothing else.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Defs, G, Path, Pattern, Rect, Text as SvgText } from 'react-native-svg';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* Dash patterns give series a second, non-colour identity (FR-064). `undefined`
|
|
14
|
+
* means a solid stroke.
|
|
15
|
+
*/
|
|
16
|
+
export function dashArrayFor(pattern) {
|
|
17
|
+
switch (pattern) {
|
|
18
|
+
case 'dashed':
|
|
19
|
+
return '6,4';
|
|
20
|
+
case 'dotted':
|
|
21
|
+
return '1,4';
|
|
22
|
+
case 'dashDot':
|
|
23
|
+
return '8,3,1,3';
|
|
24
|
+
default:
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const TEXTURE_IDS = {
|
|
29
|
+
gap: 'rnchart-texture-gap',
|
|
30
|
+
hatch: 'rnchart-texture-hatch',
|
|
31
|
+
lockedHatch: 'rnchart-texture-locked'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Texture definitions for the three non-value classes.
|
|
36
|
+
*
|
|
37
|
+
* Deliberately shape-based rather than colour-based: a reader in greyscale, or
|
|
38
|
+
* with reduced colour perception, must still tell a gap from a hatch from a
|
|
39
|
+
* locked cell (FR-064, SC-012).
|
|
40
|
+
*/
|
|
41
|
+
export function NonValueTextures({
|
|
42
|
+
theme
|
|
43
|
+
}) {
|
|
44
|
+
return /*#__PURE__*/_jsxs(Defs, {
|
|
45
|
+
children: [/*#__PURE__*/_jsxs(Pattern, {
|
|
46
|
+
id: TEXTURE_IDS.gap,
|
|
47
|
+
patternUnits: "userSpaceOnUse",
|
|
48
|
+
width: "6",
|
|
49
|
+
height: "6",
|
|
50
|
+
children: [/*#__PURE__*/_jsx(Rect, {
|
|
51
|
+
width: "6",
|
|
52
|
+
height: "6",
|
|
53
|
+
fill: theme.surface
|
|
54
|
+
}), /*#__PURE__*/_jsx(Rect, {
|
|
55
|
+
x: "2",
|
|
56
|
+
y: "2",
|
|
57
|
+
width: "1.5",
|
|
58
|
+
height: "1.5",
|
|
59
|
+
fill: theme.muted
|
|
60
|
+
})]
|
|
61
|
+
}), /*#__PURE__*/_jsxs(Pattern, {
|
|
62
|
+
id: TEXTURE_IDS.hatch,
|
|
63
|
+
patternUnits: "userSpaceOnUse",
|
|
64
|
+
width: "8",
|
|
65
|
+
height: "8",
|
|
66
|
+
children: [/*#__PURE__*/_jsx(Rect, {
|
|
67
|
+
width: "8",
|
|
68
|
+
height: "8",
|
|
69
|
+
fill: theme.surface
|
|
70
|
+
}), /*#__PURE__*/_jsx(Path, {
|
|
71
|
+
d: "M0 8L8 0",
|
|
72
|
+
stroke: theme.muted,
|
|
73
|
+
strokeWidth: "1"
|
|
74
|
+
})]
|
|
75
|
+
}), /*#__PURE__*/_jsxs(Pattern, {
|
|
76
|
+
id: TEXTURE_IDS.lockedHatch,
|
|
77
|
+
patternUnits: "userSpaceOnUse",
|
|
78
|
+
width: "8",
|
|
79
|
+
height: "8",
|
|
80
|
+
children: [/*#__PURE__*/_jsx(Rect, {
|
|
81
|
+
width: "8",
|
|
82
|
+
height: "8",
|
|
83
|
+
fill: theme.surface
|
|
84
|
+
}), /*#__PURE__*/_jsx(Path, {
|
|
85
|
+
d: "M0 8L8 0M0 0L8 8",
|
|
86
|
+
stroke: theme.muted,
|
|
87
|
+
strokeWidth: "1"
|
|
88
|
+
})]
|
|
89
|
+
})]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function fillFor(mark) {
|
|
93
|
+
if (mark.texture) {
|
|
94
|
+
return `url(#${TEXTURE_IDS[mark.texture]})`;
|
|
95
|
+
}
|
|
96
|
+
return mark.filled ? mark.color : 'none';
|
|
97
|
+
}
|
|
98
|
+
export function Marks({
|
|
99
|
+
paths
|
|
100
|
+
}) {
|
|
101
|
+
return /*#__PURE__*/_jsx(G, {
|
|
102
|
+
children: paths.map(mark => {
|
|
103
|
+
return /*#__PURE__*/_jsx(Path, {
|
|
104
|
+
d: mark.d,
|
|
105
|
+
fill: fillFor(mark),
|
|
106
|
+
stroke: mark.filled ? 'none' : mark.color,
|
|
107
|
+
strokeWidth: mark.filled ? 0 : 2,
|
|
108
|
+
strokeDasharray: mark.filled ? undefined : dashArrayFor(mark.pattern),
|
|
109
|
+
strokeLinejoin: "round",
|
|
110
|
+
strokeLinecap: "round",
|
|
111
|
+
opacity: mark.opacity ?? 1
|
|
112
|
+
}, mark.key);
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export function MarkerLines({
|
|
117
|
+
markers,
|
|
118
|
+
theme
|
|
119
|
+
}) {
|
|
120
|
+
return /*#__PURE__*/_jsx(G, {
|
|
121
|
+
children: markers.map(marker => /*#__PURE__*/_jsx(Path, {
|
|
122
|
+
d: marker.d,
|
|
123
|
+
stroke: theme.onSurface,
|
|
124
|
+
strokeWidth: 1,
|
|
125
|
+
strokeDasharray: "4,3",
|
|
126
|
+
fill: "none"
|
|
127
|
+
}, marker.id))
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export function GeometryLabels({
|
|
131
|
+
labels,
|
|
132
|
+
theme,
|
|
133
|
+
fontSize
|
|
134
|
+
}) {
|
|
135
|
+
return /*#__PURE__*/_jsx(G, {
|
|
136
|
+
children: labels.filter(label => !label.muted).map(label => /*#__PURE__*/_jsx(SvgText, {
|
|
137
|
+
x: label.x,
|
|
138
|
+
y: label.y,
|
|
139
|
+
fill: theme.typography.valueLabel.color,
|
|
140
|
+
fontSize: fontSize,
|
|
141
|
+
fontWeight: theme.typography.valueLabel.fontWeight,
|
|
142
|
+
textAnchor: label.anchor,
|
|
143
|
+
children: label.text
|
|
144
|
+
}, label.key))
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Marks the currently selected point, when it still resolves. */
|
|
149
|
+
export function SelectionHighlight({
|
|
150
|
+
x,
|
|
151
|
+
y,
|
|
152
|
+
color
|
|
153
|
+
}) {
|
|
154
|
+
return /*#__PURE__*/_jsxs(G, {
|
|
155
|
+
children: [/*#__PURE__*/_jsx(Rect, {
|
|
156
|
+
x: x - 6,
|
|
157
|
+
y: y - 6,
|
|
158
|
+
width: 12,
|
|
159
|
+
height: 12,
|
|
160
|
+
rx: 6,
|
|
161
|
+
fill: color,
|
|
162
|
+
opacity: 0.25
|
|
163
|
+
}), /*#__PURE__*/_jsx(Rect, {
|
|
164
|
+
x: x - 3,
|
|
165
|
+
y: y - 3,
|
|
166
|
+
width: 6,
|
|
167
|
+
height: 6,
|
|
168
|
+
rx: 3,
|
|
169
|
+
fill: color
|
|
170
|
+
})]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=Marks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Defs","G","Path","Pattern","Rect","Text","SvgText","jsx","_jsx","jsxs","_jsxs","dashArrayFor","pattern","undefined","TEXTURE_IDS","gap","hatch","lockedHatch","NonValueTextures","theme","children","id","patternUnits","width","height","fill","surface","x","y","muted","d","stroke","strokeWidth","fillFor","mark","texture","filled","color","Marks","paths","map","strokeDasharray","strokeLinejoin","strokeLinecap","opacity","key","MarkerLines","markers","marker","onSurface","GeometryLabels","labels","fontSize","filter","label","typography","valueLabel","fontWeight","textAnchor","anchor","text","SelectionHighlight","rx"],"sourceRoot":"../../../src","sources":["render/Marks.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,IAAIC,OAAO,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,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A,EAExBkC,KAAK,CAACM;IAAI,GARNN,KAAK,CAACT,GASH,CACT;EAAC,CACD,CAAC;AAEN;;AAEA;AACA,OAAO,SAASgB,kBAAkBA,CAAC;EAClClC,CAAC;EACDC,CAAC;EACDS;AAKD,CAAC,EAAE;EACF,oBACC3B,KAAA,CAACT,CAAC;IAAAmB,QAAA,gBACDZ,IAAA,CAACJ,IAAI;MAACuB,CAAC,EAAEA,CAAC,GAAG,CAAE;MAACC,CAAC,EAAEA,CAAC,GAAG,CAAE;MAACL,KAAK,EAAE,EAAG;MAACC,MAAM,EAAE,EAAG;MAACsC,EAAE,EAAE,CAAE;MAACrC,IAAI,EAAEY,KAAM;MAACO,OAAO,EAAE;IAAK,CAAE,CAAC,eACtFpC,IAAA,CAACJ,IAAI;MAACuB,CAAC,EAAEA,CAAC,GAAG,CAAE;MAACC,CAAC,EAAEA,CAAC,GAAG,CAAE;MAACL,KAAK,EAAE,CAAE;MAACC,MAAM,EAAE,CAAE;MAACsC,EAAE,EAAE,CAAE;MAACrC,IAAI,EAAEY;IAAM,CAAE,CAAC;EAAA,CACnE,CAAC;AAEN","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dataset budgets (FR-074, FR-075, FR-076).
|
|
5
|
+
*
|
|
6
|
+
* Over budget, the chart **still renders**. Degrading silently would break the
|
|
7
|
+
* "never present a reduced picture as complete" rule, and refusing to draw
|
|
8
|
+
* would turn a performance hint into an outage. Instead we warn the developer
|
|
9
|
+
* once, in dev builds only.
|
|
10
|
+
*
|
|
11
|
+
* The `__DEV__` gate matters: it makes the check dead code that Metro strips
|
|
12
|
+
* from release bundles, which is what makes "never in production" verifiable
|
|
13
|
+
* rather than merely intended.
|
|
14
|
+
*
|
|
15
|
+
* The figures were validated against emitted element counts in
|
|
16
|
+
* specs/007-rn-chart-package/research.md R2 — element count scales with series,
|
|
17
|
+
* not with points, so these budgets are about JS work rather than view count.
|
|
18
|
+
*/
|
|
19
|
+
import { createDiagnosticChannel } from '@chipmobilesdk/rn-core';
|
|
20
|
+
export const DATASET_BUDGETS = {
|
|
21
|
+
timeSeries: {
|
|
22
|
+
maxSeries: 5,
|
|
23
|
+
maxPointsPerSeries: 500
|
|
24
|
+
},
|
|
25
|
+
bar: {
|
|
26
|
+
maxSeries: 5,
|
|
27
|
+
maxPointsPerSeries: 60
|
|
28
|
+
},
|
|
29
|
+
distribution: {
|
|
30
|
+
maxSeries: 1,
|
|
31
|
+
maxPointsPerSeries: 12
|
|
32
|
+
},
|
|
33
|
+
progress: {
|
|
34
|
+
maxSeries: 1,
|
|
35
|
+
maxPointsPerSeries: 8
|
|
36
|
+
},
|
|
37
|
+
heatmap: {
|
|
38
|
+
maxSeries: 1,
|
|
39
|
+
maxCells: 1000
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export function checkBudget(datasource, family) {
|
|
43
|
+
const budget = DATASET_BUDGETS[family];
|
|
44
|
+
const seriesCount = datasource.series.length;
|
|
45
|
+
let maxPoints = 0;
|
|
46
|
+
let totalPoints = 0;
|
|
47
|
+
for (const series of datasource.series) {
|
|
48
|
+
maxPoints = Math.max(maxPoints, series.points.length);
|
|
49
|
+
totalPoints += series.points.length;
|
|
50
|
+
}
|
|
51
|
+
const overSeries = seriesCount > budget.maxSeries;
|
|
52
|
+
const overPoints = budget.maxPointsPerSeries !== undefined && maxPoints > budget.maxPointsPerSeries;
|
|
53
|
+
const overCells = budget.maxCells !== undefined && totalPoints > budget.maxCells;
|
|
54
|
+
return {
|
|
55
|
+
withinBudget: !overSeries && !overPoints && !overCells,
|
|
56
|
+
seriesCount,
|
|
57
|
+
maxPointsInAnySeries: maxPoints,
|
|
58
|
+
totalPoints
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const warnedCharts = new Set();
|
|
62
|
+
|
|
63
|
+
/** Chart diagnostics also reach the app's SDK sinks (`installSdkSink`, CORE-08). */
|
|
64
|
+
const channel = createDiagnosticChannel('rn-chart');
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Warns once per chart instance per mount. De-duplicating matters: a scrolling
|
|
68
|
+
* dashboard would otherwise flood the console on every frame.
|
|
69
|
+
*/
|
|
70
|
+
export function warnIfOverBudget(datasource, family, instanceKey) {
|
|
71
|
+
// Counting the dataset is dev work too: a release build skips it entirely.
|
|
72
|
+
if (!__DEV__ || warnedCharts.has(instanceKey)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const check = checkBudget(datasource, family);
|
|
76
|
+
if (!check.withinBudget) {
|
|
77
|
+
warnedCharts.add(instanceKey);
|
|
78
|
+
channel.emit('over_budget', 'warn', {
|
|
79
|
+
family,
|
|
80
|
+
series: check.seriesCount,
|
|
81
|
+
maxPoints: check.maxPointsInAnySeries
|
|
82
|
+
});
|
|
83
|
+
const budget = DATASET_BUDGETS[family];
|
|
84
|
+
console.warn(`[rn-chart] ${family} chart "${instanceKey}" exceeds its documented dataset budget ` + `(${check.seriesCount} series x up to ${check.maxPointsInAnySeries} points; ` + `budget is ${budget.maxSeries} series` + (budget.maxPointsPerSeries ? ` x ${budget.maxPointsPerSeries} points` : '') + (budget.maxCells ? `, ${budget.maxCells} cells` : '') + '). The chart still renders and drops nothing — aggregate or downsample ' + 'upstream if it feels slow. This warning appears once per chart and never ' + 'in production builds.');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Called on unmount so a remounted chart can warn again. */
|
|
89
|
+
export function releaseBudgetWarning(instanceKey) {
|
|
90
|
+
warnedCharts.delete(instanceKey);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Test-only reset. */
|
|
94
|
+
export function __resetBudgetWarnings() {
|
|
95
|
+
warnedCharts.clear();
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=budgets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createDiagnosticChannel","DATASET_BUDGETS","timeSeries","maxSeries","maxPointsPerSeries","bar","distribution","progress","heatmap","maxCells","checkBudget","datasource","family","budget","seriesCount","series","length","maxPoints","totalPoints","Math","max","points","overSeries","overPoints","undefined","overCells","withinBudget","maxPointsInAnySeries","warnedCharts","Set","channel","warnIfOverBudget","instanceKey","__DEV__","has","check","add","emit","console","warn","releaseBudgetWarning","delete","__resetBudgetWarnings","clear"],"sourceRoot":"../../../src","sources":["validation/budgets.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAuB,QAAQ,wBAAwB;AAUhE,OAAO,MAAMC,eAA6D,GAAG;EAC5EC,UAAU,EAAE;IAAEC,SAAS,EAAE,CAAC;IAAEC,kBAAkB,EAAE;EAAI,CAAC;EACrDC,GAAG,EAAE;IAAEF,SAAS,EAAE,CAAC;IAAEC,kBAAkB,EAAE;EAAG,CAAC;EAC7CE,YAAY,EAAE;IAAEH,SAAS,EAAE,CAAC;IAAEC,kBAAkB,EAAE;EAAG,CAAC;EACtDG,QAAQ,EAAE;IAAEJ,SAAS,EAAE,CAAC;IAAEC,kBAAkB,EAAE;EAAE,CAAC;EACjDI,OAAO,EAAE;IAAEL,SAAS,EAAE,CAAC;IAAEM,QAAQ,EAAE;EAAK;AACzC,CAAC;AASD,OAAO,SAASC,WAAWA,CAAIC,UAA8B,EAAEC,MAAmB,EAAe;EAChG,MAAMC,MAAM,GAAGZ,eAAe,CAACW,MAAM,CAAC;EACtC,MAAME,WAAW,GAAGH,UAAU,CAACI,MAAM,CAACC,MAAM;EAE5C,IAAIC,SAAS,GAAG,CAAC;EACjB,IAAIC,WAAW,GAAG,CAAC;EACnB,KAAK,MAAMH,MAAM,IAAIJ,UAAU,CAACI,MAAM,EAAE;IACvCE,SAAS,GAAGE,IAAI,CAACC,GAAG,CAACH,SAAS,EAAEF,MAAM,CAACM,MAAM,CAACL,MAAM,CAAC;IACrDE,WAA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