@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,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shared chart shell.
|
|
5
|
+
*
|
|
6
|
+
* Every family routes through here, so validation, status resolution, budget
|
|
7
|
+
* checks, theming, layout, selection, accessibility, and failure containment
|
|
8
|
+
* are written once and behave identically across all five. The pieces live in
|
|
9
|
+
* their own hooks and components; this file is the order they run in.
|
|
10
|
+
*
|
|
11
|
+
* Layout note (FR-039): the frame imposes **no outer margin**. Insight text is
|
|
12
|
+
* out of scope for this package, so apps render their own text directly above
|
|
13
|
+
* or below a chart and must not have to fight a margin they cannot control.
|
|
14
|
+
*/
|
|
15
|
+
import React, { useId, useMemo } from 'react';
|
|
16
|
+
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
17
|
+
import Svg from 'react-native-svg';
|
|
18
|
+
import { drawsData, suppressesInteraction } from "../contract/state.js";
|
|
19
|
+
import { chartStrings } from "../contract/strings.js";
|
|
20
|
+
import { hitTest, hitTestByX } from "../geometry/hitTest.js";
|
|
21
|
+
import { containsPoint } from "../geometry/layout.js";
|
|
22
|
+
import { EMPTY_GEOMETRY } from "../geometry/types.js";
|
|
23
|
+
import { SelectionHighlight } from "../render/Marks.js";
|
|
24
|
+
import { ChartBoundary } from "./ChartBoundary.js";
|
|
25
|
+
import { ChartLegend, ColorScaleLegend, buildLegendEntries } from "./ChartLegend.js";
|
|
26
|
+
import { ChartPlot } from "./ChartPlot.js";
|
|
27
|
+
import { ChartFailureOverlay, ChartStateOverlay } from "./ChartStateOverlay.js";
|
|
28
|
+
import { useChartTheme } from "./ChartThemeProvider.js";
|
|
29
|
+
import { pointEventFor } from "./pointEvent.js";
|
|
30
|
+
import { useChartA11y } from "./useChartA11y.js";
|
|
31
|
+
import { useChartFormatters } from "./useChartFormatters.js";
|
|
32
|
+
import { useChartLayout, useGeometryInput } from "./useChartLayout.js";
|
|
33
|
+
import { useChartSelection, useSeriesVisibility } from "./useChartSelection.js";
|
|
34
|
+
import { useChartStatus } from "./useChartStatus.js";
|
|
35
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
36
|
+
const DEFAULT_HEIGHT = 220;
|
|
37
|
+
export function ChartFrame(props) {
|
|
38
|
+
const family = props.family;
|
|
39
|
+
const theme = useChartTheme(props.theme);
|
|
40
|
+
const strings = useMemo(() => chartStrings.resolve(props.strings), [props.strings]);
|
|
41
|
+
const generatedId = useId();
|
|
42
|
+
const instanceKey = props.chartId ?? generatedId;
|
|
43
|
+
const {
|
|
44
|
+
validation,
|
|
45
|
+
error,
|
|
46
|
+
status
|
|
47
|
+
} = useChartStatus({
|
|
48
|
+
datasource: props.datasource,
|
|
49
|
+
family,
|
|
50
|
+
chartId: props.chartId,
|
|
51
|
+
instanceKey,
|
|
52
|
+
declared: props.status,
|
|
53
|
+
onFailure: props.onFailure,
|
|
54
|
+
distributionValues: props.distributionValues
|
|
55
|
+
});
|
|
56
|
+
const formatters = useChartFormatters(props.formatters, props.datasource.format, instanceKey);
|
|
57
|
+
const layout = useChartLayout(theme, {
|
|
58
|
+
height: props.height
|
|
59
|
+
});
|
|
60
|
+
const geometryInput = useGeometryInput(props.datasource, theme, layout, formatters.geometry, family);
|
|
61
|
+
const showData = drawsData(status);
|
|
62
|
+
const visibility = useSeriesVisibility({
|
|
63
|
+
controlled: props.hiddenSeriesIds,
|
|
64
|
+
onVisibilityChange: props.onVisibilityChange,
|
|
65
|
+
enabled: props.seriesToggleEnabled === true,
|
|
66
|
+
initiallyHidden: useMemo(() => props.datasource.series.filter(s => s.hidden).map(s => s.id), [props.datasource.series])
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Runtime visibility has to reach the geometry, not just the legend —
|
|
70
|
+
// otherwise toggling a series greys out its swatch while the line keeps
|
|
71
|
+
// drawing (FR-049). With nothing hidden the original datasource is returned
|
|
72
|
+
// by identity, so the common case costs nothing.
|
|
73
|
+
const hidden = visibility.hidden;
|
|
74
|
+
const datasource = useMemo(() => {
|
|
75
|
+
if (hidden.size === 0) {
|
|
76
|
+
return props.datasource;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
...props.datasource,
|
|
80
|
+
series: props.datasource.series.map(s => hidden.has(s.id) ? {
|
|
81
|
+
...s,
|
|
82
|
+
hidden: true
|
|
83
|
+
} : s)
|
|
84
|
+
};
|
|
85
|
+
}, [props.datasource, hidden]);
|
|
86
|
+
|
|
87
|
+
// The single memoized artefact.
|
|
88
|
+
//
|
|
89
|
+
// The dependency list is narrow on purpose. Depending on the whole `props`
|
|
90
|
+
// object would invalidate the memo whenever any callback identity changed —
|
|
91
|
+
// and inline arrow callbacks are the norm in app code, so that would defeat
|
|
92
|
+
// FR-073 in exactly the case it exists for. Selection is absent for the same
|
|
93
|
+
// reason: highlighting repaints the highlight, it does not rebuild scales.
|
|
94
|
+
const buildGeometry = props.buildGeometry;
|
|
95
|
+
const geometry = useMemo(() => {
|
|
96
|
+
if (!layout.measured || !showData) {
|
|
97
|
+
return EMPTY_GEOMETRY;
|
|
98
|
+
}
|
|
99
|
+
return buildGeometry(datasource, geometryInput);
|
|
100
|
+
}, [layout.measured, showData, buildGeometry, datasource, geometryInput]);
|
|
101
|
+
const selection = useChartSelection({
|
|
102
|
+
controlled: props.selection,
|
|
103
|
+
onSelectionChange: props.onSelectionChange,
|
|
104
|
+
onSelectionUnresolvable: props.onSelectionUnresolvable,
|
|
105
|
+
hitRegions: geometry.hitRegions,
|
|
106
|
+
interactionSuppressed: suppressesInteraction(status),
|
|
107
|
+
geometryReady: layout.measured && showData && geometry.hitRegions.length > 0
|
|
108
|
+
});
|
|
109
|
+
const handlePress = event => {
|
|
110
|
+
if (suppressesInteraction(status) || !props.onSelectionChange) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const {
|
|
114
|
+
locationX,
|
|
115
|
+
locationY
|
|
116
|
+
} = event.nativeEvent;
|
|
117
|
+
if (!containsPoint(geometry.plot, locationX, locationY)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const hit = props.hitTestMode === 'byX' ? hitTestByX(geometry.hitRegions, locationX) : hitTest(geometry.hitRegions, locationX, locationY);
|
|
121
|
+
if (!hit) {
|
|
122
|
+
selection.select(null, null);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const pointEvent = pointEventFor(props.datasource, hit.seriesId, hit.pointId);
|
|
126
|
+
if (pointEvent) {
|
|
127
|
+
selection.select({
|
|
128
|
+
seriesId: hit.seriesId,
|
|
129
|
+
pointId: hit.pointId
|
|
130
|
+
}, pointEvent);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const incomplete = geometry.incomplete || validation.totalIncomplete;
|
|
134
|
+
const interactive = props.accessibility?.interactive ?? Boolean(props.onSelectionChange);
|
|
135
|
+
const a11y = useChartA11y({
|
|
136
|
+
datasource: props.datasource,
|
|
137
|
+
family,
|
|
138
|
+
status,
|
|
139
|
+
title: props.title,
|
|
140
|
+
accessibility: props.accessibility,
|
|
141
|
+
interactive,
|
|
142
|
+
incomplete,
|
|
143
|
+
hitRegions: geometry.hitRegions,
|
|
144
|
+
selection,
|
|
145
|
+
formatters,
|
|
146
|
+
strings
|
|
147
|
+
});
|
|
148
|
+
const legendEnabled = props.legend === undefined ? props.defaultLegend ?? false : props.legend !== false;
|
|
149
|
+
const legendPosition = typeof props.legend === 'object' ? props.legend.position : 'bottom';
|
|
150
|
+
const legendLabel = formatters.legendLabel;
|
|
151
|
+
const legendEntries = useMemo(() => legendEnabled ? buildLegendEntries(props.datasource, theme, hidden, visibility.enabled, family, legendLabel) : [], [legendEnabled, props.datasource, theme, hidden, visibility.enabled, family, legendLabel]);
|
|
152
|
+
const legend = legendEnabled ? /*#__PURE__*/_jsx(ChartLegend, {
|
|
153
|
+
entries: legendEntries,
|
|
154
|
+
theme: theme,
|
|
155
|
+
onToggle: visibility.enabled ? visibility.toggle : undefined,
|
|
156
|
+
strings: strings
|
|
157
|
+
}) : null;
|
|
158
|
+
const plotHeight = useMemo(() => ({
|
|
159
|
+
height: props.height ?? DEFAULT_HEIGHT
|
|
160
|
+
}), [props.height]);
|
|
161
|
+
const content = /*#__PURE__*/_jsxs(_Fragment, {
|
|
162
|
+
children: [props.title ? /*#__PURE__*/_jsx(Text, {
|
|
163
|
+
style: [styles.title, {
|
|
164
|
+
color: theme.typography.valueLabel.color,
|
|
165
|
+
fontSize: theme.typography.valueLabel.fontSize
|
|
166
|
+
}],
|
|
167
|
+
accessibilityRole: "header",
|
|
168
|
+
children: props.title
|
|
169
|
+
}) : null, legendPosition === 'top' ? legend : null, /*#__PURE__*/_jsx(View, {
|
|
170
|
+
accessible: true,
|
|
171
|
+
accessibilityRole: interactive ? 'adjustable' : 'image',
|
|
172
|
+
accessibilityLabel: a11y.summary,
|
|
173
|
+
accessibilityValue: a11y.value,
|
|
174
|
+
accessibilityActions: a11y.actions,
|
|
175
|
+
onAccessibilityAction: a11y.onAction,
|
|
176
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
177
|
+
style: [styles.plotArea, plotHeight],
|
|
178
|
+
onLayout: layout.onLayout,
|
|
179
|
+
children: [layout.measured && showData ? /*#__PURE__*/_jsx(Pressable, {
|
|
180
|
+
onPress: handlePress,
|
|
181
|
+
disabled: !props.onSelectionChange,
|
|
182
|
+
style: StyleSheet.absoluteFill,
|
|
183
|
+
accessible: false,
|
|
184
|
+
importantForAccessibility: "no-hide-descendants",
|
|
185
|
+
children: /*#__PURE__*/_jsxs(Svg, {
|
|
186
|
+
width: layout.size.width,
|
|
187
|
+
height: layout.size.height,
|
|
188
|
+
children: [/*#__PURE__*/_jsx(ChartPlot, {
|
|
189
|
+
geometry: geometry,
|
|
190
|
+
theme: theme,
|
|
191
|
+
fontSize: layout.fontSize,
|
|
192
|
+
axes: props.axes ?? 'full'
|
|
193
|
+
}), selection.resolved && /*#__PURE__*/_jsx(SelectionHighlight, {
|
|
194
|
+
x: selection.resolved.x,
|
|
195
|
+
y: selection.resolved.y,
|
|
196
|
+
color: theme.onSurface
|
|
197
|
+
})]
|
|
198
|
+
})
|
|
199
|
+
}) : null, !showData || error ? /*#__PURE__*/_jsx(ChartStateOverlay, {
|
|
200
|
+
status: status,
|
|
201
|
+
supplied: props.stateContent?.[status],
|
|
202
|
+
strings: strings,
|
|
203
|
+
theme: theme,
|
|
204
|
+
error: error
|
|
205
|
+
}) : null]
|
|
206
|
+
})
|
|
207
|
+
}), legendPosition === 'bottom' ? legend : null, geometry.colorScale && props.legend !== false ? /*#__PURE__*/_jsx(ColorScaleLegend, {
|
|
208
|
+
scale: geometry.colorScale,
|
|
209
|
+
theme: theme,
|
|
210
|
+
formatValue: formatters.geometry.formatValue,
|
|
211
|
+
strings: strings
|
|
212
|
+
}) : null, incomplete ? /*#__PURE__*/_jsx(Text, {
|
|
213
|
+
style: [styles.note, {
|
|
214
|
+
color: theme.muted,
|
|
215
|
+
fontSize: theme.typography.axisLabel.fontSize
|
|
216
|
+
}],
|
|
217
|
+
children: strings['chart.note.incomplete']
|
|
218
|
+
}) : null, props.footer]
|
|
219
|
+
});
|
|
220
|
+
return /*#__PURE__*/_jsx(View, {
|
|
221
|
+
style: [styles.container, {
|
|
222
|
+
backgroundColor: theme.surface
|
|
223
|
+
}, props.style],
|
|
224
|
+
children: /*#__PURE__*/_jsx(ChartBoundary, {
|
|
225
|
+
family: props.family,
|
|
226
|
+
chartId: props.chartId,
|
|
227
|
+
onFailure: props.onFailure,
|
|
228
|
+
resetKey: props.datasource,
|
|
229
|
+
renderFallback: containedError => /*#__PURE__*/_jsx(View, {
|
|
230
|
+
accessible: true,
|
|
231
|
+
accessibilityRole: "image",
|
|
232
|
+
accessibilityLabel: a11y.summary,
|
|
233
|
+
style: [styles.plotArea, plotHeight],
|
|
234
|
+
children: /*#__PURE__*/_jsx(ChartFailureOverlay, {
|
|
235
|
+
supplied: props.stateContent?.error,
|
|
236
|
+
theme: theme,
|
|
237
|
+
error: containedError
|
|
238
|
+
})
|
|
239
|
+
}),
|
|
240
|
+
children: content
|
|
241
|
+
})
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
const styles = StyleSheet.create({
|
|
245
|
+
// No outer margin: app content must be able to sit flush against a chart.
|
|
246
|
+
container: {
|
|
247
|
+
width: '100%'
|
|
248
|
+
},
|
|
249
|
+
title: {
|
|
250
|
+
fontWeight: '600',
|
|
251
|
+
marginBottom: 4
|
|
252
|
+
},
|
|
253
|
+
plotArea: {
|
|
254
|
+
width: '100%',
|
|
255
|
+
position: 'relative'
|
|
256
|
+
},
|
|
257
|
+
// Colour and type size are applied inline from ChartTheme, so they follow
|
|
258
|
+
// the consuming app's tokens and the system text scale (UX-001).
|
|
259
|
+
note: {
|
|
260
|
+
marginTop: 4
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
//# sourceMappingURL=ChartFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useId","useMemo","Pressable","StyleSheet","Text","View","Svg","drawsData","suppressesInteraction","chartStrings","hitTest","hitTestByX","containsPoint","EMPTY_GEOMETRY","SelectionHighlight","ChartBoundary","ChartLegend","ColorScaleLegend","buildLegendEntries","ChartPlot","ChartFailureOverlay","ChartStateOverlay","useChartTheme","pointEventFor","useChartA11y","useChartFormatters","useChartLayout","useGeometryInput","useChartSelection","useSeriesVisibility","useChartStatus","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DEFAULT_HEIGHT","ChartFrame","props","family","theme","strings","resolve","generatedId","instanceKey","chartId","validation","error","status","datasource","declared","onFailure","distributionValues","formatters","format","layout","height","geometryInput","geometry","showData","visibility","controlled","hiddenSeriesIds","onVisibilityChange","enabled","seriesToggleEnabled","initiallyHidden","series","filter","s","hidden","map","id","size","has","buildGeometry","measured","selection","onSelectionChange","onSelectionUnresolvable","hitRegions","interactionSuppressed","geometryReady","length","handlePress","event","locationX","locationY","nativeEvent","plot","hit","hitTestMode","select","pointEvent","seriesId","pointId","incomplete","totalIncomplete","interactive","accessibility","Boolean","a11y","title","legendEnabled","legend","undefined","defaultLegend","legendPosition","position","legendLabel","legendEntries","entries","onToggle","toggle","plotHeight","content","children","style","styles","color","typography","valueLabel","fontSize","accessibilityRole","accessible","accessibilityLabel","summary","accessibilityValue","value","accessibilityActions","actions","onAccessibilityAction","onAction","plotArea","onLayout","onPress","disabled","absoluteFill","importantForAccessibility","width","axes","resolved","x","y","onSurface","supplied","stateContent","colorScale","scale","formatValue","note","muted","axisLabel","footer","container","backgroundColor","surface","resetKey","renderFallback","containedError","create","fontWeight","marginBottom","marginTop"],"sourceRoot":"../../../src","sources":["react/ChartFrame.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,KAAK,EAAEC,OAAO,QAAQ,OAAO;AAC7C,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAoC,cAAc;AAC5F,OAAOC,GAAG,MAAM,kBAAkB;AAKlC,SAASC,SAAS,EAAEC,qBAAqB,QAAQ,sBAAmB;AACpE,SAASC,YAAY,QAAQ,wBAAqB;AAClD,SAASC,OAAO,EAAEC,UAAU,QAAQ,wBAAqB;AACzD,SAASC,aAAa,QAAQ,uBAAoB;AAElD,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,kBAAkB,QAAQ,oBAAiB;AACpD,SAASC,aAAa,QAAQ,oBAAiB;AAC/C,SAASC,WAAW,EAAEC,gBAAgB,EAAEC,kBAAkB,QAAQ,kBAAe;AACjF,SAASC,SAAS,QAAwB,gBAAa;AACvD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tH,KAAK,CAAC+E,KAAK,CAAE;IAAAD,QAAA,eAQhFrF,IAAA,CAACjB,aAAa;MACbyB,MAAM,EAAED,KAAK,CAACC,MAAO;MACrBM,OAAO,EAAEP,KAAK,CAACO,OAAQ;MACvBM,SAAS,EAAEb,KAAK,CAACa,SAAU;MAC3B0G,QAAQ,EAAEvH,KAAK,CAACW,UAAW;MAC3B6G,cAAc,EAAEC,cAAc,iBAC7BhI,IAAA,CAAC3B,IAAI;QACJwH,UAAU;QACVD,iBAAiB,EAAC,OAAO;QACzBE,kBAAkB,EAAExB,IAAI,CAACyB,OAAQ;QACjCT,KAAK,EAAE,CAACC,MAAM,CAACe,QAAQ,EAAEnB,UAAU,CAAE;QAAAE,QAAA,eAErCrF,IAAA,CAACZ,mBAAmB;UACnB8H,QAAQ,EAAE3G,KAAK,CAAC4G,YAAY,EAAEnG,KAAM;UACpCP,KAAK,EAAEA,KAAM;UACbO,KAAK,EAAEgH;QAAe,CACtB;MAAC,CACG,CACL;MAAA3C,QAAA,EAEDD;IAAO,CACM;EAAC,CACX,CAAC;AAET;AAEA,MAAMG,MAAM,GAAGpH,UAAU,CAAC8J,MAAM,CAAC;EAChC;EACAN,SAAS,EAAE;IACVf,KAAK,EAAE;EACR,CAAC;EACDrC,KAAK,EAAE;IACN2D,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE;EACf,CAAC;EACD7B,QAAQ,EAAE;IACTM,KAAK,EAAE,MAAM;IACb/B,QAAQ,EAAE;EACX,CAAC;EACD;EACA;EACA0C,IAAI,EAAE;IACLa,SAAS,EAAE;EACZ;AACD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Legend (FR-066).
|
|
5
|
+
*
|
|
6
|
+
* On by default for multi-series and multi-segment charts, disableable, and its
|
|
7
|
+
* model is exported so an app can render its own layout instead. Every entry
|
|
8
|
+
* carries a dash pattern as well as a colour, so series stay distinguishable
|
|
9
|
+
* without colour perception.
|
|
10
|
+
*/
|
|
11
|
+
import { formatMessage } from '@chipmobilesdk/rn-core';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
14
|
+
import { chartStrings } from "../contract/strings.js";
|
|
15
|
+
import { resolveSegmentColors, resolveSeriesColor, segmentKey } from "../contract/theme.js";
|
|
16
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
/** Minimum tap target, per platform accessibility guidance (UX-003). */
|
|
18
|
+
const MIN_TAP_TARGET = 44;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Legend model. A distribution chart gets one entry per segment, in the colour
|
|
22
|
+
* its arc is drawn in; it used to get one per series, so a one-series donut of
|
|
23
|
+
* four segments showed a single entry (CHT-02).
|
|
24
|
+
*/
|
|
25
|
+
export function buildLegendEntries(datasource, theme, hidden, toggleable, family, /** The app's `legendLabel` formatter, when it has one. */
|
|
26
|
+
formatLabel = series => series.label) {
|
|
27
|
+
if (family === 'distribution') {
|
|
28
|
+
const colors = resolveSegmentColors(datasource, theme);
|
|
29
|
+
return datasource.series.flatMap(series => series.points.map(point => {
|
|
30
|
+
const single = series.points.length === 1;
|
|
31
|
+
let label = formatLabel({
|
|
32
|
+
id: series.id,
|
|
33
|
+
label: series.label
|
|
34
|
+
});
|
|
35
|
+
if (!single) {
|
|
36
|
+
label = point.position.kind === 'category' ? point.position.category : point.id;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
seriesId: series.id,
|
|
40
|
+
pointId: point.id,
|
|
41
|
+
label,
|
|
42
|
+
color: colors[segmentKey(series.id, point.id)],
|
|
43
|
+
pattern: 'solid',
|
|
44
|
+
visible: !hidden.has(series.id),
|
|
45
|
+
// Visibility is per series, so only a one-segment series toggles.
|
|
46
|
+
toggleable: toggleable && single
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
return datasource.series.map((series, index) => ({
|
|
51
|
+
seriesId: series.id,
|
|
52
|
+
label: formatLabel({
|
|
53
|
+
id: series.id,
|
|
54
|
+
label: series.label
|
|
55
|
+
}),
|
|
56
|
+
color: resolveSeriesColor(theme, index, series.color),
|
|
57
|
+
pattern: series.pattern ?? 'solid',
|
|
58
|
+
visible: !hidden.has(series.id),
|
|
59
|
+
toggleable
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
function keyOf(entry) {
|
|
63
|
+
return entry.pointId === undefined ? entry.seriesId : segmentKey(entry.seriesId, entry.pointId);
|
|
64
|
+
}
|
|
65
|
+
function segmentCountFor(pattern) {
|
|
66
|
+
switch (pattern) {
|
|
67
|
+
case 'dotted':
|
|
68
|
+
return 4;
|
|
69
|
+
case 'dashed':
|
|
70
|
+
case 'dashDot':
|
|
71
|
+
return 2;
|
|
72
|
+
default:
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function PatternSwatch({
|
|
77
|
+
entry,
|
|
78
|
+
theme
|
|
79
|
+
}) {
|
|
80
|
+
// Dashes are drawn as gapped segments so the pattern reads at swatch size —
|
|
81
|
+
// this is what gives a series an identity beyond its colour (FR-064).
|
|
82
|
+
const segments = segmentCountFor(entry.pattern);
|
|
83
|
+
const gap = segments > 1 ? 1 : 0;
|
|
84
|
+
return /*#__PURE__*/_jsx(View, {
|
|
85
|
+
style: styles.swatchRow,
|
|
86
|
+
children: Array.from({
|
|
87
|
+
length: segments
|
|
88
|
+
}, (_, i) => /*#__PURE__*/_jsx(View, {
|
|
89
|
+
style: [styles.swatchSegment, entry.visible ? styles.swatchVisible : styles.swatchHidden, {
|
|
90
|
+
width: 12 / segments - gap,
|
|
91
|
+
marginRight: gap,
|
|
92
|
+
backgroundColor: entry.visible ? entry.color : theme.muted
|
|
93
|
+
}]
|
|
94
|
+
}, i))
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
export function ChartLegend({
|
|
98
|
+
entries,
|
|
99
|
+
theme,
|
|
100
|
+
onToggle,
|
|
101
|
+
strings = chartStrings.defaults
|
|
102
|
+
}) {
|
|
103
|
+
if (entries.length === 0) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return /*#__PURE__*/_jsx(View, {
|
|
107
|
+
style: styles.container,
|
|
108
|
+
accessibilityRole: "list",
|
|
109
|
+
children: entries.map(entry => {
|
|
110
|
+
const content = /*#__PURE__*/_jsxs(_Fragment, {
|
|
111
|
+
children: [/*#__PURE__*/_jsx(PatternSwatch, {
|
|
112
|
+
entry: entry,
|
|
113
|
+
theme: theme
|
|
114
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
115
|
+
style: [styles.label, {
|
|
116
|
+
color: entry.visible ? theme.typography.legendLabel.color : theme.muted,
|
|
117
|
+
fontSize: theme.typography.legendLabel.fontSize
|
|
118
|
+
}],
|
|
119
|
+
numberOfLines: 1,
|
|
120
|
+
children: entry.label
|
|
121
|
+
})]
|
|
122
|
+
});
|
|
123
|
+
if (!entry.toggleable || !onToggle) {
|
|
124
|
+
return /*#__PURE__*/_jsx(View, {
|
|
125
|
+
style: styles.entry,
|
|
126
|
+
accessibilityRole: "text",
|
|
127
|
+
children: content
|
|
128
|
+
}, keyOf(entry));
|
|
129
|
+
}
|
|
130
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
131
|
+
onPress: () => onToggle(entry.seriesId),
|
|
132
|
+
accessibilityRole: "switch",
|
|
133
|
+
accessibilityState: {
|
|
134
|
+
checked: entry.visible
|
|
135
|
+
},
|
|
136
|
+
accessibilityLabel: entry.label,
|
|
137
|
+
accessibilityHint: entry.visible ? strings['chart.legend.hide'] : strings['chart.legend.show'],
|
|
138
|
+
style: [styles.entry, styles.tappable],
|
|
139
|
+
children: content
|
|
140
|
+
}, keyOf(entry));
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The key to a colour ramp: its lowest and highest value around the colours
|
|
147
|
+
* between them. Without it a heatmap's shades meant nothing (CHT-15).
|
|
148
|
+
*/
|
|
149
|
+
export function ColorScaleLegend({
|
|
150
|
+
scale,
|
|
151
|
+
theme,
|
|
152
|
+
formatValue,
|
|
153
|
+
strings = chartStrings.defaults
|
|
154
|
+
}) {
|
|
155
|
+
const min = formatValue(scale.min);
|
|
156
|
+
const max = formatValue(scale.max);
|
|
157
|
+
const text = {
|
|
158
|
+
color: theme.typography.legendLabel.color,
|
|
159
|
+
fontSize: theme.typography.legendLabel.fontSize
|
|
160
|
+
};
|
|
161
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
162
|
+
style: styles.scale,
|
|
163
|
+
accessible: true,
|
|
164
|
+
accessibilityRole: "text",
|
|
165
|
+
accessibilityLabel: formatMessage(strings['chart.legend.scale'], {
|
|
166
|
+
min,
|
|
167
|
+
max
|
|
168
|
+
}),
|
|
169
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
170
|
+
style: text,
|
|
171
|
+
children: min
|
|
172
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
173
|
+
style: styles.scaleRamp,
|
|
174
|
+
children: scale.colors.map((color, index) => /*#__PURE__*/_jsx(View, {
|
|
175
|
+
style: [styles.scaleStep, {
|
|
176
|
+
backgroundColor: color
|
|
177
|
+
}]
|
|
178
|
+
}, `${index}-${color}`))
|
|
179
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
180
|
+
style: text,
|
|
181
|
+
children: max
|
|
182
|
+
})]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const styles = StyleSheet.create({
|
|
186
|
+
scale: {
|
|
187
|
+
flexDirection: 'row',
|
|
188
|
+
alignItems: 'center',
|
|
189
|
+
marginTop: 4
|
|
190
|
+
},
|
|
191
|
+
scaleRamp: {
|
|
192
|
+
flexDirection: 'row',
|
|
193
|
+
marginHorizontal: 8
|
|
194
|
+
},
|
|
195
|
+
scaleStep: {
|
|
196
|
+
width: 16,
|
|
197
|
+
height: 8
|
|
198
|
+
},
|
|
199
|
+
container: {
|
|
200
|
+
flexDirection: 'row',
|
|
201
|
+
flexWrap: 'wrap',
|
|
202
|
+
alignItems: 'center'
|
|
203
|
+
},
|
|
204
|
+
entry: {
|
|
205
|
+
flexDirection: 'row',
|
|
206
|
+
alignItems: 'center',
|
|
207
|
+
marginRight: 12,
|
|
208
|
+
marginTop: 4
|
|
209
|
+
},
|
|
210
|
+
tappable: {
|
|
211
|
+
minHeight: MIN_TAP_TARGET,
|
|
212
|
+
paddingVertical: 4
|
|
213
|
+
},
|
|
214
|
+
swatchRow: {
|
|
215
|
+
flexDirection: 'row',
|
|
216
|
+
alignItems: 'center',
|
|
217
|
+
width: 12,
|
|
218
|
+
marginRight: 6
|
|
219
|
+
},
|
|
220
|
+
swatchSegment: {
|
|
221
|
+
height: 3,
|
|
222
|
+
borderRadius: 2
|
|
223
|
+
},
|
|
224
|
+
swatchVisible: {
|
|
225
|
+
opacity: 1
|
|
226
|
+
},
|
|
227
|
+
swatchHidden: {
|
|
228
|
+
opacity: 0.4
|
|
229
|
+
},
|
|
230
|
+
label: {
|
|
231
|
+
flexShrink: 1
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
//# sourceMappingURL=ChartLegend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatMessage","React","Pressable","StyleSheet","Text","View","chartStrings","resolveSegmentColors","resolveSeriesColor","segmentKey","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","MIN_TAP_TARGET","buildLegendEntries","datasource","theme","hidden","toggleable","family","formatLabel","series","label","colors","flatMap","points","map","point","single","length","id","position","kind","category","seriesId","pointId","color","pattern","visible","has","index","keyOf","entry","undefined","segmentCountFor","PatternSwatch","segments","gap","style","styles","swatchRow","children","Array","from","_","i","swatchSegment","swatchVisible","swatchHidden","width","marginRight","backgroundColor","muted","ChartLegend","entries","onToggle","strings","defaults","container","accessibilityRole","content","typography","legendLabel","fontSize","numberOfLines","onPress","accessibilityState","checked","accessibilityLabel","accessibilityHint","tappable","ColorScaleLegend","scale","formatValue","min","max","text","accessible","scaleRamp","scaleStep","create","flexDirection","alignItems","marginTop","marginHorizontal","height","flexWrap","minHeight","paddingVertical","borderRadius","opacity","flexShrink"],"sourceRoot":"../../../src","sources":["react/ChartLegend.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,wBAAwB;AACtD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAIhE,SAASC,YAAY,QAA2B,wBAAqB;AACrE,SACCC,oBAAoB,EACpBC,kBAAkB,EAClBC,UAAU,QAGJ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAG3B;AACA,MAAMC,cAAc,GAAG,EAAE;;AAEzB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CACjCC,UAA8B,EAC9BC,KAAiB,EACjBC,MAA2B,EAC3BC,UAAmB,EACnBC,MAAoB,EACpB;AACAC,WAA0C,GAAGC,MAAM,IAAIA,MAAM,CAACC,KAAK,EACnD;EAChB,IAAIH,MAAM,KAAK,cAAc,EAAE;IAC9B,MAAMI,MAAM,GAAGnB,oBAAoB,CAACW,UAAU,EAAEC,KAAK,CAAC;IACtD,OAAOD,UAAU,CAACM,MAAM,CAACG,OAAO,CAACH,MAAM,IACtCA,MAAM,CAACI,MAAM,CAACC,GAAG,CAACC,KAAK,IAAI;MAC1B,MAAMC,MAAM,GAAGP,MAAM,CAACI,MAAM,CAACI,MAAM,KAAK,CAAC;MACzC,IAAIP,KAAK,GAAGF,WAAW,CAAC;QAAEU,EAAE,EAAET,MAAM,CAACS,EAAE;QAAER,KAAK,EAAED,MAAM,CAACC;MAAM,CAAC,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
+
/**
|
|
4
|
+
* Everything the chart draws from its geometry.
|
|
5
|
+
*
|
|
6
|
+
* Memoized on the geometry: selecting a point re-renders the frame and moves
|
|
7
|
+
* the highlight, and this subtree — the long path strings — is skipped
|
|
8
|
+
* (CHT-08). It used to be reconciled again on every tap.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { Grid, XAxis, YAxis } from "../render/Axis.js";
|
|
12
|
+
import { GeometryLabels, MarkerLines, Marks, NonValueTextures } from "../render/Marks.js";
|
|
13
|
+
|
|
14
|
+
/** `labels` names rows and columns without drawing axis lines or a grid. */
|
|
15
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
export const ChartPlot = /*#__PURE__*/React.memo(function ChartPlot({
|
|
17
|
+
geometry,
|
|
18
|
+
theme,
|
|
19
|
+
fontSize,
|
|
20
|
+
axes
|
|
21
|
+
}) {
|
|
22
|
+
const lines = axes === 'full';
|
|
23
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
24
|
+
children: [/*#__PURE__*/_jsx(NonValueTextures, {
|
|
25
|
+
theme: theme
|
|
26
|
+
}), axes !== 'none' && /*#__PURE__*/_jsxs(_Fragment, {
|
|
27
|
+
children: [lines && /*#__PURE__*/_jsx(Grid, {
|
|
28
|
+
plot: geometry.plot,
|
|
29
|
+
yTicks: geometry.yTicks,
|
|
30
|
+
theme: theme
|
|
31
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
32
|
+
plot: geometry.plot,
|
|
33
|
+
ticks: geometry.yTicks,
|
|
34
|
+
theme: theme,
|
|
35
|
+
fontSize: fontSize,
|
|
36
|
+
line: lines
|
|
37
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
38
|
+
plot: geometry.plot,
|
|
39
|
+
ticks: geometry.xTicks,
|
|
40
|
+
theme: theme,
|
|
41
|
+
fontSize: fontSize,
|
|
42
|
+
line: lines
|
|
43
|
+
})]
|
|
44
|
+
}), /*#__PURE__*/_jsx(Marks, {
|
|
45
|
+
paths: geometry.paths
|
|
46
|
+
}), /*#__PURE__*/_jsx(MarkerLines, {
|
|
47
|
+
markers: geometry.markers,
|
|
48
|
+
theme: theme
|
|
49
|
+
}), /*#__PURE__*/_jsx(GeometryLabels, {
|
|
50
|
+
labels: geometry.labels,
|
|
51
|
+
theme: theme,
|
|
52
|
+
fontSize: fontSize
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=ChartPlot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Grid","XAxis","YAxis","GeometryLabels","MarkerLines","Marks","NonValueTextures","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ChartPlot","memo","geometry","theme","fontSize","axes","lines","children","plot","yTicks","ticks","line","xTicks","paths","markers","labels"],"sourceRoot":"../../../src","sources":["react/ChartPlot.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,IAAI,EAAEC,KAAK,EAAEC,KAAK,QAAQ,mBAAgB;AACnD,SAASC,cAAc,EAAEC,WAAW,EAAEC,KAAK,EAAEC,gBAAgB,QAAQ,oBAAiB;;AAEtF;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAGA,OAAO,MAAMC,SAAS,gBAAGd,KAAK,CAACe,IAAI,CAAC,SAASD,SAASA,CAAC;EACtDE,QAAQ;EACRC,KAAK;EACLC,QAAQ;EACRC;AAMD,CAAC,EAAE;EACF,MAAMC,KAAK,GAAGD,IAAI,KAAK,MAAM;EAC7B,oBACCN,KAAA,CAAAF,SAAA;IAAAU,QAAA,gBACCZ,IAAA,CAACF,gBAAgB;MAACU,KAAK,EAAEA;IAAM,CAAE,CAAC,EACjCE,IAAI,KAAK,MAAM,iBACfN,KAAA,CAAAF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