@chipmobilesdk/rn-chart 0.4.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 +111 -0
- package/README.md +1 -1
- 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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a chart shows in place of data: the app's own content for the state,
|
|
5
|
+
* or a terse built-in line. Apps are expected to supply their own copy — the
|
|
6
|
+
* package must not impose product voice.
|
|
7
|
+
*/
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
function builtInStateText(status, strings, error) {
|
|
12
|
+
switch (status) {
|
|
13
|
+
case 'loading':
|
|
14
|
+
return strings['chart.state.loading'];
|
|
15
|
+
case 'empty':
|
|
16
|
+
return strings['chart.state.empty'];
|
|
17
|
+
case 'error':
|
|
18
|
+
return error?.message ?? strings['chart.state.error'];
|
|
19
|
+
case 'noPermission':
|
|
20
|
+
return strings['chart.state.noPermission'];
|
|
21
|
+
default:
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function ChartStateOverlay({
|
|
26
|
+
status,
|
|
27
|
+
supplied,
|
|
28
|
+
strings,
|
|
29
|
+
theme,
|
|
30
|
+
error
|
|
31
|
+
}) {
|
|
32
|
+
if (supplied !== undefined) {
|
|
33
|
+
return /*#__PURE__*/_jsx(View, {
|
|
34
|
+
style: styles.overlay,
|
|
35
|
+
children: supplied
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const fallback = builtInStateText(status, strings, error);
|
|
39
|
+
if (!fallback) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/_jsx(View, {
|
|
43
|
+
style: styles.overlay,
|
|
44
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
45
|
+
style: {
|
|
46
|
+
color: theme.muted,
|
|
47
|
+
fontSize: theme.typography.valueLabel.fontSize
|
|
48
|
+
},
|
|
49
|
+
children: fallback
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The message a contained render failure shows where the plot was. */
|
|
55
|
+
export function ChartFailureOverlay({
|
|
56
|
+
supplied,
|
|
57
|
+
theme,
|
|
58
|
+
error
|
|
59
|
+
}) {
|
|
60
|
+
return /*#__PURE__*/_jsx(View, {
|
|
61
|
+
style: styles.overlay,
|
|
62
|
+
children: supplied ?? /*#__PURE__*/_jsx(Text, {
|
|
63
|
+
style: {
|
|
64
|
+
color: theme.muted,
|
|
65
|
+
fontSize: theme.typography.valueLabel.fontSize
|
|
66
|
+
},
|
|
67
|
+
children: error.message
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const styles = StyleSheet.create({
|
|
72
|
+
overlay: {
|
|
73
|
+
position: 'absolute',
|
|
74
|
+
top: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
right: 0,
|
|
77
|
+
bottom: 0,
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
justifyContent: 'center'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=ChartStateOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","Text","View","jsx","_jsx","builtInStateText","status","strings","error","message","undefined","ChartStateOverlay","supplied","theme","style","styles","overlay","children","fallback","color","muted","fontSize","typography","valueLabel","ChartFailureOverlay","create","position","top","left","right","bottom","alignItems","justifyContent"],"sourceRoot":"../../../src","sources":["react/ChartStateOverlay.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOtD,SAASC,gBAAgBA,CACxBC,MAAmB,EACnBC,OAAqB,EACrBC,KAAkB,EACG;EACrB,QAAQF,MAAM;IACb,KAAK,SAAS;MACb,OAAOC,OAAO,CAAC,qBAAqB,CAAC;IACtC,KAAK,OAAO;MACX,OAAOA,OAAO,CAAC,mBAAmB,CAAC;IACpC,KAAK,OAAO;MACX,OAAOC,KAAK,EAAEC,OAAO,IAAIF,OAAO,CAAC,mBAAmB,CAAC;IACtD,KAAK,cAAc;MAClB,OAAOA,OAAO,CAAC,0BAA0B,CAAC;IAC3C;MACC,OAAOG,SAAS;EAClB;AACD;AAEA,OAAO,SAASC,iBAAiBA,CAAC;EACjCL,MAAM;EACNM,QAAQ;EACRL,OAAO;EACPM,KAAK;EACLL;AAQD,CAAC,EAAE;EACF,IAAII,QAAQ,KAAKF,SAAS,EAAE;IAC3B,oBAAON,IAAA,CAACF,IAAI;MAACY,KAAK,EAAEC,MAAM,CAACC,OAAQ;MAAAC,QAAA,EAAEL;IAAQ,CAAO,CAAC;EACtD;EACA,MAAMM,QAAQ,GAAGb,gBAAgB,CAACC,MAAM,EAAEC,OAAO,EAAEC,KAAK,CAAC;EACzD,IAAI,CAACU,QAAQ,EAAE;IACd,OAAO,IAAI;EACZ;EACA,oBACCd,IAAA,CAACF,IAAI;IAACY,KAAK,EAAEC,MAAM,CAACC,OAAQ;IAAAC,QAAA,eAC3Bb,IAAA,CAACH,IAAI;MAACa,KAAK,EAAE;QAAEK,KAAK,EAAEN,KAAK,CAACO,KAAK;QAAEC,QAAQ,EAAER,KAAK,CAACS,UAAU,CAACC,UAAU,CAACF;MAAS,CAAE;MAAAJ,QAAA,EAClFC;IAAQ,CACJ;EAAC,CACF,CAAC;AAET;;AAEA;AACA,OAAO,SAASM,mBAAmBA,CAAC;EACnCZ,QAAQ;EACRC,KAAK;EACLL;AAKD,CAAC,EAAE;EACF,oBACCJ,IAAA,CAACF,IAAI;IAACY,KAAK,EAAEC,MAAM,CAACC,OAAQ;IAAAC,QAAA,EAC1BL,QAAQ,iBACRR,IAAA,CAACH,IAAI;MAACa,KAAK,EAAE;QAAEK,KAAK,EAAEN,KAAK,CAACO,KAAK;QAAEC,QAAQ,EAAER,KAAK,CAACS,UAAU,CAACC,UAAU,CAACF;MAAS,CAAE;MAAAJ,QAAA,EAClFT,KAAK,CAACC;IAAO,CACT;EACN,CACI,CAAC;AAET;AAEA,MAAMM,MAAM,GAAGf,UAAU,CAACyB,MAAM,CAAC;EAChCT,OAAO,EAAE;IACRU,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EACjB;AACD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Theme resolution: prop -> context -> built-in default keyed on the OS scheme.
|
|
5
|
+
*
|
|
6
|
+
* The dependency is inverted on purpose. The package declares a `ChartTheme`
|
|
7
|
+
* value type and any design system can satisfy it, which is what keeps
|
|
8
|
+
* `@chipmobilesdk/rn-theme` and `react-native-unistyles` out of this package
|
|
9
|
+
* entirely (FR-065, LIB-004).
|
|
10
|
+
*/
|
|
11
|
+
import React, { createContext, useContext, useMemo } from 'react';
|
|
12
|
+
import { useColorScheme } from 'react-native';
|
|
13
|
+
import { defaultChartTheme } from "../contract/theme.js";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const ChartThemeContext = /*#__PURE__*/createContext(undefined);
|
|
16
|
+
export function ChartThemeProvider({
|
|
17
|
+
theme,
|
|
18
|
+
children
|
|
19
|
+
}) {
|
|
20
|
+
return /*#__PURE__*/_jsx(ChartThemeContext.Provider, {
|
|
21
|
+
value: theme,
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An explicit prop wins, then context, then the built-in default for the
|
|
28
|
+
* current OS colour scheme — so a chart renders correctly with no theme
|
|
29
|
+
* configuration at all.
|
|
30
|
+
*/
|
|
31
|
+
export function useChartTheme(explicit) {
|
|
32
|
+
const fromContext = useContext(ChartThemeContext);
|
|
33
|
+
const scheme = useColorScheme();
|
|
34
|
+
return useMemo(() => {
|
|
35
|
+
if (explicit) {
|
|
36
|
+
return explicit;
|
|
37
|
+
}
|
|
38
|
+
if (fromContext) {
|
|
39
|
+
return fromContext;
|
|
40
|
+
}
|
|
41
|
+
return defaultChartTheme(scheme === 'dark' ? 'dark' : 'light');
|
|
42
|
+
}, [explicit, fromContext, scheme]);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=ChartThemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","useMemo","useColorScheme","defaultChartTheme","jsx","_jsx","ChartThemeContext","undefined","ChartThemeProvider","theme","children","Provider","value","useChartTheme","explicit","fromContext","scheme"],"sourceRoot":"../../../src","sources":["react/ChartThemeProvider.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AACjE,SAASC,cAAc,QAAQ,cAAc;AAE7C,SAASC,iBAAiB,QAAyB,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEvE,MAAMC,iBAAiB,gBAAGP,aAAa,CAAyBQ,SAAS,CAAC;AAE1E,OAAO,SAASC,kBAAkBA,CAAC;EAClCC,KAAK;EACLC;AAID,CAAC,EAAE;EACF,oBAAOL,IAAA,CAACC,iBAAiB,CAACK,QAAQ;IAACC,KAAK,EAAEH,KAAM;IAAAC,QAAA,EAAEA;EAAQ,CAA6B,CAAC;AACzF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,aAAaA,CAACC,QAAqB,EAAc;EAChE,MAAMC,WAAW,GAAGf,UAAU,CAACM,iBAAiB,CAAC;EACjD,MAAMU,MAAM,GAAGd,cAAc,CAAC,CAAC;EAE/B,OAAOD,OAAO,CAAC,MAAM;IACpB,IAAIa,QAAQ,EAAE;MACb,OAAOA,QAAQ;IAChB;IACA,IAAIC,WAAW,EAAE;MAChB,OAAOA,WAAW;IACnB;IACA,OAAOZ,iBAAiB,CAACa,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;EAC/D,CAAC,EAAE,CAACF,QAAQ,EAAEC,WAAW,EAAEC,MAAM,CAAC,CAAC;AACpC","ignoreList":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The five chart family components.
|
|
5
|
+
*
|
|
6
|
+
* Each is a thin wrapper over `ChartFrame` plus its own geometry builder, so
|
|
7
|
+
* validation, state handling, theming, selection, accessibility, and failure
|
|
8
|
+
* containment behave identically across every family.
|
|
9
|
+
*
|
|
10
|
+
* All five are wrapped in `React.memo`: value-identical props stop at the memo
|
|
11
|
+
* boundary and never reach geometry (FR-073, SC-017).
|
|
12
|
+
*/
|
|
13
|
+
import React, { useCallback } from 'react';
|
|
14
|
+
import { buildBarGeometry } from "../geometry/bar.js";
|
|
15
|
+
import { buildDistributionGeometry } from "../geometry/distribution.js";
|
|
16
|
+
import { buildHeatmapGeometry } from "../geometry/heatmap.js";
|
|
17
|
+
import { buildProgressGeometry } from "../geometry/progress.js";
|
|
18
|
+
import { buildTimeSeriesGeometry } from "../geometry/timeSeries.js";
|
|
19
|
+
import { ChartFrame } from "./ChartFrame.js";
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
+
function ProgressChartImpl(props) {
|
|
22
|
+
const build = useCallback((ds, input) => buildProgressGeometry(ds, input), []);
|
|
23
|
+
return /*#__PURE__*/_jsx(ChartFrame, {
|
|
24
|
+
...props,
|
|
25
|
+
family: "progress",
|
|
26
|
+
buildGeometry: build,
|
|
27
|
+
axes: "none",
|
|
28
|
+
defaultLegend: false
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function DistributionChartImpl(props) {
|
|
32
|
+
const build = useCallback((ds, input) => buildDistributionGeometry(ds, input, {
|
|
33
|
+
shape: props.shape,
|
|
34
|
+
innerRadiusRatio: props.innerRadiusRatio,
|
|
35
|
+
valuesAre: props.valuesAre
|
|
36
|
+
}), [props.shape, props.innerRadiusRatio, props.valuesAre]);
|
|
37
|
+
return /*#__PURE__*/_jsx(ChartFrame, {
|
|
38
|
+
...props,
|
|
39
|
+
family: "distribution",
|
|
40
|
+
buildGeometry: build,
|
|
41
|
+
distributionValues: props.valuesAre,
|
|
42
|
+
axes: "none",
|
|
43
|
+
defaultLegend: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function TimeSeriesChartImpl(props) {
|
|
47
|
+
// By value: `range={{ from, to }}` written inline is a new object each render.
|
|
48
|
+
const from = props.range?.from;
|
|
49
|
+
const to = props.range?.to;
|
|
50
|
+
const build = useCallback((ds, input) => buildTimeSeriesGeometry(ds, input, from === undefined || to === undefined ? {} : {
|
|
51
|
+
range: {
|
|
52
|
+
from,
|
|
53
|
+
to
|
|
54
|
+
}
|
|
55
|
+
}), [from, to]);
|
|
56
|
+
return /*#__PURE__*/_jsx(ChartFrame, {
|
|
57
|
+
...props,
|
|
58
|
+
family: "timeSeries",
|
|
59
|
+
buildGeometry: build
|
|
60
|
+
// A user aims at a moment in time, not at a pixel on the line.
|
|
61
|
+
,
|
|
62
|
+
hitTestMode: "byX",
|
|
63
|
+
defaultLegend: true
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function BarChartImpl(props) {
|
|
67
|
+
const build = useCallback((ds, input) => buildBarGeometry(ds, input, {
|
|
68
|
+
grouping: props.grouping
|
|
69
|
+
}), [props.grouping]);
|
|
70
|
+
return /*#__PURE__*/_jsx(ChartFrame, {
|
|
71
|
+
...props,
|
|
72
|
+
family: "bar",
|
|
73
|
+
buildGeometry: build,
|
|
74
|
+
defaultLegend: true
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function HeatmapChartImpl(props) {
|
|
78
|
+
const build = useCallback((ds, input) => buildHeatmapGeometry(ds, input, {
|
|
79
|
+
buckets: props.buckets
|
|
80
|
+
}), [props.buckets]);
|
|
81
|
+
return /*#__PURE__*/_jsx(ChartFrame, {
|
|
82
|
+
...props,
|
|
83
|
+
family: "heatmap",
|
|
84
|
+
buildGeometry: build
|
|
85
|
+
// Rows and columns are named; there is no axis line or grid to draw.
|
|
86
|
+
,
|
|
87
|
+
axes: "labels",
|
|
88
|
+
defaultLegend: false
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* `React.memo` erases the generic parameter, so each component is re-cast to a
|
|
94
|
+
* generic function type. This keeps `<BarChart<MyMeta> ... />` working for
|
|
95
|
+
* consumers while still getting the memo boundary.
|
|
96
|
+
*/
|
|
97
|
+
export const ProgressChart = /*#__PURE__*/React.memo(ProgressChartImpl);
|
|
98
|
+
export const DistributionChart = /*#__PURE__*/React.memo(DistributionChartImpl);
|
|
99
|
+
export const TimeSeriesChart = /*#__PURE__*/React.memo(TimeSeriesChartImpl);
|
|
100
|
+
export const BarChart = /*#__PURE__*/React.memo(BarChartImpl);
|
|
101
|
+
export const HeatmapChart = /*#__PURE__*/React.memo(HeatmapChartImpl);
|
|
102
|
+
//# sourceMappingURL=charts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","buildBarGeometry","buildDistributionGeometry","buildHeatmapGeometry","buildProgressGeometry","buildTimeSeriesGeometry","ChartFrame","jsx","_jsx","ProgressChartImpl","props","build","ds","input","family","buildGeometry","axes","defaultLegend","DistributionChartImpl","shape","innerRadiusRatio","valuesAre","distributionValues","TimeSeriesChartImpl","from","range","to","undefined","hitTestMode","BarChartImpl","grouping","HeatmapChartImpl","buckets","ProgressChart","memo","DistributionChart","TimeSeriesChart","BarChart","HeatmapChart"],"sourceRoot":"../../../src","sources":["react/charts.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAK1C,SAASC,gBAAgB,QAA0B,oBAAiB;AACpE,SAASC,yBAAyB,QAAgC,6BAA0B;AAC5F,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,qBAAqB,QAAQ,yBAAsB;AAC5D,SAASC,uBAAuB,QAAQ,2BAAwB;AAEhE,SAASC,UAAU,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAI1C,SAASC,iBAAiBA,CAAIC,KAA4B,EAAE;EAC3D,MAAMC,KAAK,GAAGX,WAAW,CACxB,CAACY,EAAsB,EAAEC,KAAoB,KAAKT,qBAAqB,CAACQ,EAAE,EAAEC,KAAK,CAAC,EAClF,EACD,CAAC;EAED,oBACCL,IAAA,CAACF,UAAU;IAAA,GACNI,KAAK;IACTI,MAAM,EAA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Y,CAExB;AAEvB,OAAO,MAAMS,YAAY,gBAAGvC,KAAK,CAACmC,IAAI,CAACH,gBAAgB,CAEhC","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The event a selected point is reported with. One place builds it, for a tap
|
|
5
|
+
* and for a screen-reader step alike.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function findPoint(datasource, seriesId, pointId) {
|
|
9
|
+
const series = datasource.series.find(s => s.id === seriesId);
|
|
10
|
+
const point = series?.points.find(p => p.id === pointId);
|
|
11
|
+
return series && point ? {
|
|
12
|
+
series,
|
|
13
|
+
point
|
|
14
|
+
} : undefined;
|
|
15
|
+
}
|
|
16
|
+
export function pointEventFor(datasource, seriesId, pointId) {
|
|
17
|
+
const found = findPoint(datasource, seriesId, pointId);
|
|
18
|
+
if (!found) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
type: 'pointSelect',
|
|
23
|
+
seriesId: found.series.id,
|
|
24
|
+
pointId: found.point.id,
|
|
25
|
+
value: found.point.value,
|
|
26
|
+
position: found.point.position,
|
|
27
|
+
metadata: found.point.metadata
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=pointEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["findPoint","datasource","seriesId","pointId","series","find","s","id","point","points","p","undefined","pointEventFor","found","type","value","position","metadata"],"sourceRoot":"../../../src","sources":["react/pointEvent.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AASA,OAAO,SAASA,SAASA,CACxBC,UAA8B,EAC9BC,QAAgB,EAChBC,OAA2B,EACI;EAC/B,MAAMC,MAAM,GAAGH,UAAU,CAACG,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,EAAE,KAAKL,QAAQ,CAAC;EAC7D,MAAMM,KAAK,GAAGJ,MAAM,EAAEK,MAAM,CAACJ,IAAI,CAACK,CAAC,IAAIA,CAAC,CAACH,EAAE,KAAKJ,OAAO,CAAC;EACxD,OAAOC,MAAM,IAAII,KAAK,GAAG;IAAEJ,MAAM;IAAEI;EAAM,CAAC,GAAGG,SAAS;AACvD;AAEA,OAAO,SAASC,aAAaA,CAC5BX,UAA8B,EAC9BC,QAAgB,EAChBC,OAAe,EACwB;EACvC,MAAMU,KAAK,GAAGb,SAAS,CAACC,UAAU,EAAEC,QAAQ,EAAEC,OAAO,CAAC;EACtD,IAAI,CAACU,KAAK,EAAE;IACX,OAAOF,SAAS;EACjB;EACA,OAAO;IACNG,IAAI,EAAE,aAAa;IACnBZ,QAAQ,EAAEW,KAAK,CAACT,MAAM,CAACG,EAAE;IACzBJ,OAAO,EAAEU,KAAK,CAACL,KAAK,CAACD,EAAE;IACvBQ,KAAK,EAAEF,KAAK,CAACL,KAAK,CAACO,KAAK;IACxBC,QAAQ,EAAEH,KAAK,CAACL,KAAK,CAACQ,QAAQ;IAC9BC,QAAQ,EAAEJ,KAAK,CAACL,KAAK,CAACS;EACvB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a screen reader gets: the composed summary, the announcement for the
|
|
5
|
+
* selected point, and increment/decrement to walk the points (FR-052, FR-067,
|
|
6
|
+
* FR-072).
|
|
7
|
+
*/
|
|
8
|
+
import { useMemo } from 'react';
|
|
9
|
+
import { buildChartSummary, buildPointAnnouncement } from "../a11y/summary.js";
|
|
10
|
+
import { findPoint, pointEventFor } from "./pointEvent.js";
|
|
11
|
+
export function useChartA11y(args) {
|
|
12
|
+
const {
|
|
13
|
+
datasource,
|
|
14
|
+
family,
|
|
15
|
+
status,
|
|
16
|
+
title,
|
|
17
|
+
incomplete,
|
|
18
|
+
formatters,
|
|
19
|
+
strings,
|
|
20
|
+
selection
|
|
21
|
+
} = args;
|
|
22
|
+
const label = args.accessibility?.label;
|
|
23
|
+
const summaryFormatter = args.accessibility?.summaryFormatter;
|
|
24
|
+
const summary = useMemo(() => {
|
|
25
|
+
if (label) {
|
|
26
|
+
return label;
|
|
27
|
+
}
|
|
28
|
+
// The app's own composer, when given.
|
|
29
|
+
if (summaryFormatter) {
|
|
30
|
+
return summaryFormatter(datasource, {
|
|
31
|
+
slot: 'summary',
|
|
32
|
+
hint: datasource.format
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return buildChartSummary({
|
|
36
|
+
datasource,
|
|
37
|
+
family,
|
|
38
|
+
status,
|
|
39
|
+
title,
|
|
40
|
+
formatValue: formatters.formatSummaryValue,
|
|
41
|
+
formatPosition: formatters.formatPosition,
|
|
42
|
+
incomplete,
|
|
43
|
+
strings
|
|
44
|
+
});
|
|
45
|
+
}, [label, summaryFormatter, datasource, family, status, title, formatters, incomplete, strings]);
|
|
46
|
+
if (!args.interactive) {
|
|
47
|
+
return {
|
|
48
|
+
summary,
|
|
49
|
+
value: undefined,
|
|
50
|
+
actions: undefined,
|
|
51
|
+
onAction: undefined
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const selected = selection.resolved ? findPoint(datasource, selection.resolved.seriesId, selection.resolved.pointId) : undefined;
|
|
55
|
+
return {
|
|
56
|
+
summary,
|
|
57
|
+
value: selected ? {
|
|
58
|
+
text: buildPointAnnouncement(selected.series.label,
|
|
59
|
+
// The app's own wording for a position: a raw epoch number is
|
|
60
|
+
// not something to read aloud (CHT-07).
|
|
61
|
+
formatters.formatPosition(selected.point.position), selected.point.value, formatters.formatSummaryValue, strings)
|
|
62
|
+
} : undefined,
|
|
63
|
+
actions: [{
|
|
64
|
+
name: 'increment',
|
|
65
|
+
label: strings['chart.action.next']
|
|
66
|
+
}, {
|
|
67
|
+
name: 'decrement',
|
|
68
|
+
label: strings['chart.action.previous']
|
|
69
|
+
}],
|
|
70
|
+
onAction: event => {
|
|
71
|
+
const regions = args.hitRegions.filter(r => r.selectable);
|
|
72
|
+
if (regions.length === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const step = event.nativeEvent.actionName === 'increment' ? 1 : -1;
|
|
76
|
+
const current = regions.findIndex(r => r.seriesId === selection.selection?.seriesId && r.pointId === selection.selection?.pointId);
|
|
77
|
+
const next = regions[current < 0 ? 0 : (current + step + regions.length) % regions.length];
|
|
78
|
+
const pointEvent = pointEventFor(datasource, next.seriesId, next.pointId);
|
|
79
|
+
if (!pointEvent) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Stepping moves the selection; it never clears it.
|
|
83
|
+
selection.select({
|
|
84
|
+
seriesId: next.seriesId,
|
|
85
|
+
pointId: next.pointId
|
|
86
|
+
}, pointEvent, {
|
|
87
|
+
toggle: false
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=useChartA11y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","buildChartSummary","buildPointAnnouncement","findPoint","pointEventFor","useChartA11y","args","datasource","family","status","title","incomplete","formatters","strings","selection","label","accessibility","summaryFormatter","summary","slot","hint","format","formatValue","formatSummaryValue","formatPosition","interactive","value","undefined","actions","onAction","selected","resolved","seriesId","pointId","text","series","point","position","name","event","regions","hitRegions","filter","r","selectable","length","step","nativeEvent","actionName","current","findIndex","next","pointEvent","select","toggle"],"sourceRoot":"../../../src","sources":["react/useChartA11y.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,OAAO;AAE/B,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,oBAAiB;AAM3E,SAASC,SAAS,EAAEC,aAAa,QAAQ,iBAAc;AAyBvD,OAAO,SAASC,YAAYA,CAAIC,IAAyB,EAAa;EACrE,MAAM;IAAEC,UAAU;IAAEC,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAA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AQ,EAAEmB,IAAI,CAACnB,QAAQ;QAAEC,OAAO,EAAEkB,IAAI,CAAClB;MAAQ,CAAC,EAAEmB,UAAU,EAAE;QAChFE,MAAM,EAAE;MACT,CAAC,CAAC;IACH;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The app's formatters, resolved once into the functions the chart calls.
|
|
5
|
+
*
|
|
6
|
+
* The memo depends on each formatter **function**, not on the `formatters`
|
|
7
|
+
* object that carries them. `formatters={{ value: formatMoney }}` written
|
|
8
|
+
* inline is a new object every render; depending on it rebuilt every scale and
|
|
9
|
+
* path each time the parent rendered (CHT-08, PERF-11). A formatter function
|
|
10
|
+
* that is itself created inline still counts as a change — it may format
|
|
11
|
+
* differently — so keep those stable (module scope, or `useCallback`).
|
|
12
|
+
*/
|
|
13
|
+
import { useMemo } from 'react';
|
|
14
|
+
import { formatPositionDefault, formatValueDefault, safeFormat } from "../contract/format.js";
|
|
15
|
+
export function useChartFormatters(formatters, hint, instanceKey) {
|
|
16
|
+
const value = formatters?.value;
|
|
17
|
+
const axisLabel = formatters?.axisLabel;
|
|
18
|
+
const legend = formatters?.legendLabel;
|
|
19
|
+
const summary = formatters?.summary;
|
|
20
|
+
return useMemo(() => {
|
|
21
|
+
const formatValue = v => value ? safeFormat(() => value(v, {
|
|
22
|
+
slot: 'value',
|
|
23
|
+
hint
|
|
24
|
+
}), () => formatValueDefault(v, {
|
|
25
|
+
slot: 'value',
|
|
26
|
+
hint
|
|
27
|
+
}), 'value', instanceKey) : formatValueDefault(v, {
|
|
28
|
+
slot: 'value',
|
|
29
|
+
hint
|
|
30
|
+
});
|
|
31
|
+
const formatSummaryValue = v => summary ? safeFormat(() => summary(v, {
|
|
32
|
+
slot: 'summary',
|
|
33
|
+
hint
|
|
34
|
+
}), () => formatValue(v), 'summary', instanceKey) : formatValue(v);
|
|
35
|
+
const formatPosition = position => axisLabel ? safeFormat(() => axisLabel(position, {
|
|
36
|
+
slot: 'axis'
|
|
37
|
+
}), () => formatPositionDefault(position), 'axis', instanceKey) : formatPositionDefault(position);
|
|
38
|
+
return {
|
|
39
|
+
formatValue,
|
|
40
|
+
formatSummaryValue,
|
|
41
|
+
formatPosition,
|
|
42
|
+
...(legend ? {
|
|
43
|
+
legendLabel: series => safeFormat(() => legend(series, {
|
|
44
|
+
slot: 'legend'
|
|
45
|
+
}), () => series.label, 'legend', instanceKey)
|
|
46
|
+
} : {}),
|
|
47
|
+
geometry: {
|
|
48
|
+
formatValue: n => formatValue({
|
|
49
|
+
kind: 'known',
|
|
50
|
+
value: n
|
|
51
|
+
}),
|
|
52
|
+
formatCategory: raw => raw,
|
|
53
|
+
formatInstant: at => formatPosition({
|
|
54
|
+
kind: 'instant',
|
|
55
|
+
at
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}, [value, axisLabel, legend, summary, hint, instanceKey]);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=useChartFormatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","formatPositionDefault","formatValueDefault","safeFormat","useChartFormatters","formatters","hint","instanceKey","value","axisLabel","legend","legendLabel","summary","formatValue","v","slot","formatSummaryValue","formatPosition","position","series","label","geometry","n","kind","formatCategory","raw","formatInstant","at"],"sourceRoot":"../../../src","sources":["react/useChartFormatters.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,OAAO;AAG/B,SACCC,qBAAqB,EACrBC,kBAAkB,EAClBC,UAAU,QAIJ,uBAAoB;AAqB3B,OAAO,SAASC,kBAAkBA,CACjCC,UAAuC,EACvCC,IAA4B,EAC5BC,WAAmB,EACE;EACrB,MAAMC,KAAK,GAAGH,UAAU,EAAEG,KAAK;EAC/B,MAAMC,SAAS,GAAGJ,UAAU,EAAEI,S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C,CAAC;MACNc,QAAQ,EAAE;QACTR,WAAW,EAAGS,CAAS,IAAKT,WAAW,CAAC;UAAEU,IAAI,EAAE,OAAO;UAAEf,KAAK,EAAEc;QAAE,CAAC,CAAC;QACpEE,cAAc,EAAGC,GAAW,IAAKA,GAAG;QACpCC,aAAa,EAAGC,EAAU,IAAKV,cAAc,CAAC;UAAEM,IAAI,EAAE,SAAS;UAAEI;QAAG,CAAC;MACtE;IACD,CAAC;EACF,CAAC,EAAE,CAACnB,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEE,OAAO,EAAEN,IAAI,EAAEC,WAAW,CAAC,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Container measurement and the geometry memo.
|
|
5
|
+
*
|
|
6
|
+
* `ResolvedGeometry` is memoized on datasource identity, plot rectangle, theme
|
|
7
|
+
* identity, and formatter identity — and deliberately **not** on selection, so
|
|
8
|
+
* highlighting a point repaints the highlight without recomputing scales or
|
|
9
|
+
* path strings (FR-073, SC-017).
|
|
10
|
+
*
|
|
11
|
+
* A consequence worth documenting for consumers: rebuilding the datasource
|
|
12
|
+
* object inline on every render defeats this. The README says so, and the demo
|
|
13
|
+
* app models the correct pattern.
|
|
14
|
+
*/
|
|
15
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
16
|
+
import { useWindowDimensions } from 'react-native';
|
|
17
|
+
import { resolveSegmentColors, resolveSeriesColor } from "../contract/theme.js";
|
|
18
|
+
import { EMPTY_PLOT, isMeasurable, resolvePlotRect } from "../geometry/layout.js";
|
|
19
|
+
import { effectiveFontSize } from "../geometry/layout.js";
|
|
20
|
+
export function useChartLayout(theme, options = {}) {
|
|
21
|
+
const [size, setSize] = useState({
|
|
22
|
+
width: 0,
|
|
23
|
+
height: 0
|
|
24
|
+
});
|
|
25
|
+
const onLayout = useCallback(event => {
|
|
26
|
+
const {
|
|
27
|
+
width,
|
|
28
|
+
height
|
|
29
|
+
} = event.nativeEvent.layout;
|
|
30
|
+
setSize(prev =>
|
|
31
|
+
// Avoid a state churn loop on sub-pixel layout jitter.
|
|
32
|
+
Math.abs(prev.width - width) < 0.5 && Math.abs(prev.height - height) < 0.5 ? prev : {
|
|
33
|
+
width,
|
|
34
|
+
height
|
|
35
|
+
});
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
// Reactive: a change of the system text size re-renders the chart. A value
|
|
39
|
+
// read once from PixelRatio kept the old size until something else rendered.
|
|
40
|
+
const {
|
|
41
|
+
fontScale
|
|
42
|
+
} = useWindowDimensions();
|
|
43
|
+
const fontSize = effectiveFontSize(theme.typography.axisLabel.fontSize, fontScale);
|
|
44
|
+
const measured = isMeasurable(size);
|
|
45
|
+
const plot = useMemo(() => {
|
|
46
|
+
if (!measured) {
|
|
47
|
+
// Wait for a real measurement rather than computing a broken layout
|
|
48
|
+
// or throwing (FR-078).
|
|
49
|
+
return EMPTY_PLOT;
|
|
50
|
+
}
|
|
51
|
+
return resolvePlotRect({
|
|
52
|
+
container: size,
|
|
53
|
+
xLabels: options.xLabels,
|
|
54
|
+
yLabels: options.yLabels,
|
|
55
|
+
baseFontSize: theme.typography.axisLabel.fontSize,
|
|
56
|
+
fontScale,
|
|
57
|
+
padding: theme.spacing.xs
|
|
58
|
+
});
|
|
59
|
+
}, [measured, size, options.xLabels, options.yLabels, theme.typography.axisLabel.fontSize, theme.spacing.xs, fontScale]);
|
|
60
|
+
return {
|
|
61
|
+
onLayout,
|
|
62
|
+
size,
|
|
63
|
+
measured,
|
|
64
|
+
plot,
|
|
65
|
+
fontSize
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Builds the geometry input, resolving per-series colours once so geometry
|
|
71
|
+
* modules never reach into the theme themselves.
|
|
72
|
+
*/
|
|
73
|
+
export function useGeometryInput(datasource, theme, layout, formatters, family) {
|
|
74
|
+
return useMemo(() => {
|
|
75
|
+
const seriesColors = {};
|
|
76
|
+
datasource.series.forEach((series, index) => {
|
|
77
|
+
seriesColors[series.id] = resolveSeriesColor(theme, index, series.color);
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
plot: layout.plot,
|
|
81
|
+
fontSize: layout.fontSize,
|
|
82
|
+
seriesColors,
|
|
83
|
+
// Per point only where segments exist; resolving one per point for
|
|
84
|
+
// every family cost a colour per data point at the time-series budget.
|
|
85
|
+
segmentColors: family === 'distribution' ? resolveSegmentColors(datasource, theme) : undefined,
|
|
86
|
+
nonValueTextures: theme.nonValue,
|
|
87
|
+
heatmapRamp: theme.heatmapRamp,
|
|
88
|
+
radius: theme.radius,
|
|
89
|
+
formatValue: formatters.formatValue,
|
|
90
|
+
formatCategory: formatters.formatCategory,
|
|
91
|
+
formatInstant: formatters.formatInstant
|
|
92
|
+
};
|
|
93
|
+
}, [datasource, theme, layout.plot, layout.fontSize, formatters, family]);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=useChartLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useMemo","useState","useWindowDimensions","resolveSegmentColors","resolveSeriesColor","EMPTY_PLOT","isMeasurable","resolvePlotRect","effectiveFontSize","useChartLayout","theme","options","size","setSize","width","height","onLayout","event","nativeEvent","layout","prev","Math","abs","fontScale","fontSize","typography","axisLabel","measured","plot","container","xLabels","yLabels","baseFontSize","padding","spacing","xs","useGeometryInput","datasource","formatters","family","seriesColors","series","forEach","index","id","color","segmentColors","undefined","nonValueTextures","nonValue","heatmapRamp","radius","formatValue","formatCategory","formatInstant"],"sourceRoot":"../../../src","sources":["react/useChartLayout.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACtD,SAASC,mBAAmB,QAAgC,cAAc;AAG1E,SAASC,oBAAoB,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