@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,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NON_VALUE_TEXT = void 0;
|
|
7
|
+
exports.__resetFormatterWarnings = __resetFormatterWarnings;
|
|
8
|
+
exports.formatLegendDefault = formatLegendDefault;
|
|
9
|
+
exports.formatPositionDefault = formatPositionDefault;
|
|
10
|
+
exports.formatValueDefault = formatValueDefault;
|
|
11
|
+
exports.safeFormat = safeFormat;
|
|
12
|
+
exports.seriesRef = seriesRef;
|
|
13
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
14
|
+
var _value = require("./value.js");
|
|
15
|
+
/**
|
|
16
|
+
* Formatting contract (FR-055 to FR-059).
|
|
17
|
+
*
|
|
18
|
+
* The package never invents or converts a business unit. It accepts a hint,
|
|
19
|
+
* applies a documented locale-neutral default, and uses app-supplied formatter
|
|
20
|
+
* output verbatim whenever one is given.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** Chart diagnostics also reach the app's SDK sinks (`installSdkSink`, CORE-08). */
|
|
24
|
+
const channel = (0, _rnCore.createDiagnosticChannel)('rn-chart');
|
|
25
|
+
/**
|
|
26
|
+
* Placeholders for the three non-value classes. Deliberately not "0" and not
|
|
27
|
+
* an empty string, so a reader can tell a gap from a zero at a glance.
|
|
28
|
+
*/
|
|
29
|
+
const NON_VALUE_TEXT = exports.NON_VALUE_TEXT = {
|
|
30
|
+
unknown: '—',
|
|
31
|
+
notApplicable: 'n/a',
|
|
32
|
+
withheld: '••'
|
|
33
|
+
};
|
|
34
|
+
function trimTrailingZeros(text) {
|
|
35
|
+
return text.includes('.') ? text.replace(/\.?0+$/, '') : text;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Locale-neutral default formatting (FR-057).
|
|
40
|
+
*
|
|
41
|
+
* Deliberately plain: no thousands separators, no currency symbol lookup, no
|
|
42
|
+
* month names. Anything locale-dependent belongs to the consuming app, which
|
|
43
|
+
* owns an i18n system the package does not.
|
|
44
|
+
*/
|
|
45
|
+
function formatValueDefault(v, ctx = {
|
|
46
|
+
slot: 'value'
|
|
47
|
+
}) {
|
|
48
|
+
if (!(0, _value.isKnown)(v)) {
|
|
49
|
+
return NON_VALUE_TEXT[v.kind] ?? NON_VALUE_TEXT.unknown;
|
|
50
|
+
}
|
|
51
|
+
const hint = ctx.hint;
|
|
52
|
+
const n = v.value;
|
|
53
|
+
switch (hint?.kind) {
|
|
54
|
+
case 'percent':
|
|
55
|
+
{
|
|
56
|
+
const decimals = hint.decimals ?? 0;
|
|
57
|
+
return `${(n * 100).toFixed(decimals)}%`;
|
|
58
|
+
}
|
|
59
|
+
case 'currency':
|
|
60
|
+
// Code rather than symbol: symbol placement is locale-dependent and
|
|
61
|
+
// therefore the app's decision.
|
|
62
|
+
return `${n.toFixed(2)} ${hint.currency}`;
|
|
63
|
+
case 'duration':
|
|
64
|
+
return `${trimTrailingZeros(n.toFixed(2))}${hint.unit}`;
|
|
65
|
+
case 'count':
|
|
66
|
+
return String(Math.round(n));
|
|
67
|
+
case 'custom':
|
|
68
|
+
return `${trimTrailingZeros(n.toFixed(2))} ${hint.unit}`;
|
|
69
|
+
case 'number':
|
|
70
|
+
return hint.decimals === undefined ? trimTrailingZeros(n.toFixed(2)) : n.toFixed(hint.decimals);
|
|
71
|
+
default:
|
|
72
|
+
return trimTrailingZeros(n.toFixed(2));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function formatPositionDefault(p) {
|
|
76
|
+
switch (p.kind) {
|
|
77
|
+
case 'category':
|
|
78
|
+
return p.category;
|
|
79
|
+
case 'matrix':
|
|
80
|
+
return `${p.row} / ${p.column}`;
|
|
81
|
+
case 'instant':
|
|
82
|
+
// Epoch milliseconds as-is. Any human-readable date belongs to an app
|
|
83
|
+
// formatter, which alone knows the locale and the display timezone
|
|
84
|
+
// (FR-016).
|
|
85
|
+
return String(p.at);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function formatLegendDefault(series) {
|
|
89
|
+
return series.label;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Runs an app formatter, falling back to the package default for that single
|
|
94
|
+
* label if it throws (FR-059). One bad formatter must not take down a screen.
|
|
95
|
+
*
|
|
96
|
+
* The dev-only warning is intentionally value-free: it names the slot, never
|
|
97
|
+
* the data.
|
|
98
|
+
*/
|
|
99
|
+
function safeFormat(run, fallback, slot, onceKey) {
|
|
100
|
+
try {
|
|
101
|
+
return run();
|
|
102
|
+
} catch (e) {
|
|
103
|
+
if (__DEV__) {
|
|
104
|
+
warnFormatterFailureOnce(slot, onceKey, e);
|
|
105
|
+
}
|
|
106
|
+
return fallback();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const warnedFormatters = new Set();
|
|
110
|
+
function warnFormatterFailureOnce(slot, onceKey, error) {
|
|
111
|
+
const key = `${slot}:${onceKey ?? 'default'}`;
|
|
112
|
+
if (warnedFormatters.has(key)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
warnedFormatters.add(key);
|
|
116
|
+
channel.emit('formatter_threw', 'warn', {
|
|
117
|
+
slot
|
|
118
|
+
});
|
|
119
|
+
const reason = error instanceof Error ? error.message : 'unknown error';
|
|
120
|
+
console.warn(`[rn-chart] A supplied "${slot}" formatter threw (${reason}). ` + 'Falling back to the built-in default for that label. ' + 'This warning appears once per formatter slot and never in production builds.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Test-only reset so warning-once behaviour can be asserted repeatedly. */
|
|
124
|
+
function __resetFormatterWarnings() {
|
|
125
|
+
warnedFormatters.clear();
|
|
126
|
+
}
|
|
127
|
+
function seriesRef(series) {
|
|
128
|
+
return {
|
|
129
|
+
id: series.id,
|
|
130
|
+
label: series.label
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","_value","channel","createDiagnosticChannel","NON_VALUE_TEXT","exports","unknown","notApplicable","withheld","trimTrailingZeros","text","includes","replace","formatValueDefault","v","ctx","slot","isKnown","kind","hint","n","value","decimals","toFixed","currency","unit","String","Math","round","undefined","formatPositionDefault","p","category","row","column","at","formatLegendDefault","series","label","safeFormat","run","fallback","onceKey","e","__DEV__","warnFormatterFailureOnce","warnedFormatters","Set","error","key","has","add","emit","reason","Error","message","console","warn","__resetFormatterWarnings","clear","seriesRef","id"],"sourceRoot":"../../../src","sources":["contract/format.ts"],"mappings":";;;;;;;;;;;;AAOA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA,MAAME,O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OAA2B,EAC3BM,KAAc,EACP;EACP,MAAMC,GAAG,GAAG,GAAGjC,IAAI,IAAI0B,OAAO,IAAI,SAAS,EAAE;EAC7C,IAAII,gBAAgB,CAACI,GAAG,CAACD,GAAG,CAAC,EAAE;IAC9B;EACD;EACAH,gBAAgB,CAACK,GAAG,CAACF,GAAG,CAAC;EACzB/C,OAAO,CAACkD,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE;IAAEpC;EAAK,CAAC,CAAC;EACjD,MAAMqC,MAAM,GAAGL,KAAK,YAAYM,KAAK,GAAGN,KAAK,CAACO,OAAO,GAAG,eAAe;EACvEC,OAAO,CAACC,IAAI,CACX,0BAA0BzC,IAAI,sBAAsBqC,MAAM,KAAK,GAC9D,uDAAuD,GACvD,8EACF,CAAC;AACF;;AAEA;AACO,SAASK,wBAAwBA,CAAA,EAAS;EAChDZ,gBAAgB,CAACa,KAAK,CAAC,CAAC;AACzB;AAEO,SAASC,SAASA,CAAIvB,MAAiB,EAAa;EAC1D,OAAO;IAAEwB,EAAE,EAAExB,MAAM,CAACwB,EAAE;IAAEvB,KAAK,EAAED,MAAM,CAACC;EAAM,CAAC;AAC9C","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sameSelection = sameSelection;
|
|
7
|
+
/**
|
|
8
|
+
* Interaction contract (FR-048 to FR-054a).
|
|
9
|
+
*
|
|
10
|
+
* The package reports what the user touched and does nothing else: no
|
|
11
|
+
* navigation, no fetching, no datasource mutation, no business rules.
|
|
12
|
+
*
|
|
13
|
+
* Selection is **uncontrolled by default and controlled when the app supplies a
|
|
14
|
+
* value** — the standard React pattern. The same callbacks fire either way, so
|
|
15
|
+
* a consumer can move between the two without rewriting handlers.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function sameSelection(a, b) {
|
|
19
|
+
if (!a || !b) {
|
|
20
|
+
return !a && !b;
|
|
21
|
+
}
|
|
22
|
+
return a.seriesId === b.seriesId && a.pointId === b.pointId;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["sameSelection","a","b","seriesId","pointId"],"sourceRoot":"../../../src","sources":["contract/interaction.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoDO,SAASA,aAAaA,CAC5BC,CAAkC,EAClCC,CAAkC,EACxB;EACV,IAAI,CAACD,CAAC,IAAI,CAACC,CAAC,EAAE;IACb,OAAO,CAACD,CAAC,IAAI,CAACC,CAAC;EAChB;EACA,OAAOD,CAAC,CAACE,QAAQ,KAAKD,CAAC,CAACC,QAAQ,IAAIF,CAAC,CAACG,OAAO,KAAKF,CAAC,CAACE,OAAO;AAC5D","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findTarget = findTarget;
|
|
7
|
+
exports.isUsableTarget = isUsableTarget;
|
|
8
|
+
exports.readProgress = readProgress;
|
|
9
|
+
var _value = require("./value.js");
|
|
10
|
+
/**
|
|
11
|
+
* Reference markers: targets, baselines, and thresholds (FR-008, FR-021, FR-022).
|
|
12
|
+
*
|
|
13
|
+
* The important rule lives here: a marker whose value is not `known`, or whose
|
|
14
|
+
* target is zero or negative, produces **no completion proportion**. A chart
|
|
15
|
+
* shows the current value alone rather than inventing a percentage.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A target only supports a proportion when it is known and strictly positive.
|
|
20
|
+
* Zero and negative targets make "percent complete" meaningless, so we decline
|
|
21
|
+
* to compute one rather than divide and produce a nonsense figure.
|
|
22
|
+
*/
|
|
23
|
+
function isUsableTarget(marker) {
|
|
24
|
+
if (!marker || marker.kind !== 'target') {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return (0, _value.isKnown)(marker.value) && marker.value.value > 0;
|
|
28
|
+
}
|
|
29
|
+
function readProgress(current, target) {
|
|
30
|
+
if (!(0, _value.isKnown)(current) || !isUsableTarget(target) || !target) {
|
|
31
|
+
return {
|
|
32
|
+
current,
|
|
33
|
+
target,
|
|
34
|
+
proportion: undefined,
|
|
35
|
+
overshoot: false
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// isUsableTarget already proved the target is known and positive.
|
|
40
|
+
const targetValue = target.value.value;
|
|
41
|
+
const proportion = current.value / targetValue;
|
|
42
|
+
return {
|
|
43
|
+
current,
|
|
44
|
+
target,
|
|
45
|
+
proportion,
|
|
46
|
+
overshoot: proportion > 1
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function findTarget(markers, id) {
|
|
50
|
+
if (!markers) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return markers.find(m => m.kind === 'target' && (!id || m.id === id));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_value","require","isUsableTarget","marker","kind","isKnown","value","readProgress","current","target","proportion","undefined","overshoot","targetValue","findTarget","markers","id","find","m"],"sourceRoot":"../../../src","sources":["contract/marker.ts"],"mappings":";;;;;;;;AAQA,IAAAA,MAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,MAAmC,EAAW;EAC5E,IAAI,CAACA,MAAM,IAAIA,MAAM,CAACC,IAAI,KAAK,QAAQ,EAAE;IACxC,OAAO,KAAK;EACb;EACA,OAAO,IAAAC,cAAO,EAACF,MAAM,CAACG,KAAK,CAAC,IAAIH,MAAM,CAACG,KAAK,CAACA,KAAK,GAAG,CAAC;AACvD;AAgBO,SAASC,YAAYA,CAC3BC,OAAmB,EACnBC,MAAmC,EACjB;EAClB,IAAI,CAAC,IAAAJ,cAAO,EAACG,OAAO,CAAC,IAAI,CAACN,cAAc,CAACO,MAAM,CAAC,IAAI,CAACA,MAAM,EAAE;IAC5D,OAAO;MAAED,OAAO;MAAEC,MAAM;MAAEC,UAAU,EAAEC,SAAS;MAAEC,SAAS,EAAE;IAAM,CAAC;EACpE;;EAEA;EACA,MAAMC,WAAW,GAAIJ,MAAM,CAACH,KAAK,CAAuBA,KAAK;EAC7D,MAAMI,UAAU,GAAGF,OAAO,CAACF,KAAK,GAAGO,WAAW;EAE9C,OAAO;IACNL,OAAO;IACPC,MAAM;IACNC,UAAU;IACVE,SAAS,EAAEF,UAAU,GAAG;EACzB,CAAC;AACF;AAEO,SAASI,UAAUA,CACzBC,OAA+C,EAC/CC,EAAW,EACmB;EAC9B,IAAI,CAACD,OAAO,EAAE;IACb,OAAOJ,SAAS;EACjB;EACA,OAAOI,OAAO,CAACE,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACd,IAAI,KAAK,QAAQ,KAAK,CAACY,EAAE,IAAIE,CAAC,CAACF,EAAE,KAAKA,EAAE,CAAC,CAAC;AACtE","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/props.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.STATUS_PRECEDENCE = void 0;
|
|
7
|
+
exports.drawsData = drawsData;
|
|
8
|
+
exports.resolveStatus = resolveStatus;
|
|
9
|
+
exports.suppressesInteraction = suppressesInteraction;
|
|
10
|
+
/**
|
|
11
|
+
* Chart status contract (FR-029 to FR-038).
|
|
12
|
+
*
|
|
13
|
+
* Ownership is split on a simple principle: the package derives what only the
|
|
14
|
+
* data can determine, and the app declares what only the app can know.
|
|
15
|
+
*
|
|
16
|
+
* empty, partial -> derived from the datasource
|
|
17
|
+
* loading, stale, -> declared by the app: it alone knows about its own
|
|
18
|
+
* noPermission, fetches, cache age, access rules, and failures
|
|
19
|
+
* error
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** The statuses an app may declare. `empty` and `partial` are derived. */
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resolution precedence, highest first.
|
|
26
|
+
*
|
|
27
|
+
* `noPermission` outranks everything so restricted values can never slip
|
|
28
|
+
* through some other state. `stale` and `partial` sit below the blocking
|
|
29
|
+
* states because they are modifiers on a chart that still draws its data.
|
|
30
|
+
*/
|
|
31
|
+
const STATUS_PRECEDENCE = exports.STATUS_PRECEDENCE = ['noPermission', 'error', 'loading', 'empty', 'stale', 'partial', 'ready'];
|
|
32
|
+
function resolveStatus(inputs) {
|
|
33
|
+
const candidates = new Set(['ready']);
|
|
34
|
+
if (inputs.declared) {
|
|
35
|
+
candidates.add(inputs.declared);
|
|
36
|
+
}
|
|
37
|
+
if (inputs.error) {
|
|
38
|
+
candidates.add('error');
|
|
39
|
+
}
|
|
40
|
+
if (inputs.isEmpty) {
|
|
41
|
+
candidates.add('empty');
|
|
42
|
+
}
|
|
43
|
+
if (inputs.isPartial) {
|
|
44
|
+
candidates.add('partial');
|
|
45
|
+
}
|
|
46
|
+
for (const status of STATUS_PRECEDENCE) {
|
|
47
|
+
if (candidates.has(status)) {
|
|
48
|
+
return status;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return 'ready';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Statuses in which the chart draws its data (possibly with an indicator). */
|
|
55
|
+
function drawsData(status) {
|
|
56
|
+
return status === 'ready' || status === 'stale' || status === 'partial';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Statuses in which no data-selection callback may fire, because the chart is
|
|
61
|
+
* not displaying the values a callback would carry (FR-053).
|
|
62
|
+
*/
|
|
63
|
+
function suppressesInteraction(status) {
|
|
64
|
+
return !drawsData(status);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Per-status content the app supplies, replacing any package wording (FR-035). */
|
|
68
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["STATUS_PRECEDENCE","exports","resolveStatus","inputs","candidates","Set","declared","add","error","isEmpty","isPartial","status","has","drawsData","suppressesInteraction"],"sourceRoot":"../../../src","sources":["contract/state.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,iBAAyC,GAAAC,OAAA,CAAAD,iBAAA,GAAG,CACxD,cAAc,EACd,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,SAAS,EACT,OAAO,CACP;AAaM,SAASE,aAAaA,CAACC,MAAoB,EAAe;EAChE,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAc,CAAC,OAAO,CAAC,CAAC;EAElD,IAAIF,MAAM,CAACG,QAAQ,EAAE;IACpBF,UAAU,CAACG,GAAG,CAACJ,MAAM,CAACG,QAAQ,CAAC;EAChC;EACA,IAAIH,MAAM,CAACK,KAAK,EAAE;IACjBJ,UAAU,CAACG,GAAG,CAAC,OAAO,CAAC;EACxB;EACA,IAAIJ,MAAM,CAACM,OAAO,EAAE;IACnBL,UAAU,CAACG,GAAG,CAAC,OAAO,CAAC;EACxB;EACA,IAAIJ,MAAM,CAACO,SAAS,EAAE;IACrBN,UAAU,CAACG,GAAG,CAAC,SAAS,CAAC;EAC1B;EAEA,KAAK,MAAMI,MAAM,IAAIX,iBAAiB,EAAE;IACvC,IAAII,UAAU,CAACQ,GAAG,CAACD,MAAM,CAAC,EAAE;MAC3B,OAAOA,MAAM;IACd;EACD;EACA,OAAO,OAAO;AACf;;AAEA;AACO,SAASE,SAASA,CAACF,MAAmB,EAAW;EACvD,OAAOA,MAAM,KAAK,OAAO,IAAIA,MAAM,KAAK,OAAO,IAAIA,MAAM,KAAK,SAAS;AACxE;;AAEA;AACA;AACA;AACA;AACO,SAASG,qBAAqBA,CAACH,MAAmB,EAAW;EACnE,OAAO,CAACE,SAAS,CAACF,MAAM,CAAC;AAC1B;;AAEA","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.chartStrings = void 0;
|
|
7
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
8
|
+
/**
|
|
9
|
+
* Every text the package itself speaks or shows (CHT-05): screen-reader
|
|
10
|
+
* summaries and announcements, adjustable-action labels, built-in state text and
|
|
11
|
+
* legend hints. English defaults; an app translates them by passing `strings`
|
|
12
|
+
* (or by registering `chartStrings.user` with rn-i18n and passing the translated
|
|
13
|
+
* texts). `{name}` marks a variable.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const chartStrings = exports.chartStrings = (0, _rnCore.defineMessages)({
|
|
17
|
+
user: {
|
|
18
|
+
'chart.family.progress': 'progress chart',
|
|
19
|
+
'chart.family.distribution': 'distribution chart',
|
|
20
|
+
'chart.family.timeSeries': 'time series chart',
|
|
21
|
+
'chart.family.bar': 'bar chart',
|
|
22
|
+
'chart.family.heatmap': 'heatmap',
|
|
23
|
+
'chart.status.loading': 'Loading data.',
|
|
24
|
+
'chart.status.empty': 'No data yet.',
|
|
25
|
+
'chart.status.error': 'Data could not be shown.',
|
|
26
|
+
'chart.status.stale': 'Showing data that may be out of date.',
|
|
27
|
+
'chart.status.noPermission': 'This data is not available to you.',
|
|
28
|
+
'chart.status.partial': 'Some data is missing.',
|
|
29
|
+
'chart.summary.heading': '{title}, {noun}.',
|
|
30
|
+
'chart.summary.headingUntitled': '{noun}.',
|
|
31
|
+
'chart.summary.scale': '{series} series, {points} points.',
|
|
32
|
+
'chart.summary.scaleSingle': '{points} points.',
|
|
33
|
+
'chart.summary.single': 'Value {value}.',
|
|
34
|
+
'chart.summary.extremes': 'Highest {maxLabel} at {max}. Lowest {minLabel} at {min}.',
|
|
35
|
+
'chart.summary.marker': '{name} {value}',
|
|
36
|
+
'chart.summary.incomplete': 'Some values are missing, so totals are incomplete.',
|
|
37
|
+
'chart.point.withheld': '{position}, {series}, not available.',
|
|
38
|
+
'chart.point.noData': '{position}, {series}, no data.',
|
|
39
|
+
'chart.point.value': '{position}, {series}, {value}.',
|
|
40
|
+
'chart.total': 'Total {value}.',
|
|
41
|
+
'chart.total.incomplete': 'Total {value}, excluding {count} values that are not available.',
|
|
42
|
+
'chart.action.next': 'Next data point',
|
|
43
|
+
'chart.action.previous': 'Previous data point',
|
|
44
|
+
'chart.state.loading': 'Loading…',
|
|
45
|
+
'chart.state.empty': 'No data yet',
|
|
46
|
+
'chart.state.error': 'Unable to show this chart',
|
|
47
|
+
'chart.state.noPermission': 'Not available',
|
|
48
|
+
'chart.legend.hide': 'Hides this series',
|
|
49
|
+
'chart.legend.show': 'Shows this series',
|
|
50
|
+
'chart.legend.scale': 'Colour scale from {min} to {max}',
|
|
51
|
+
'chart.note.incomplete': 'Some values are unavailable, so totals are incomplete.'
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","chartStrings","exports","defineMessages","user"],"sourceRoot":"../../../src","sources":["contract/strings.ts"],"mappings":";;;;;;AAOA,IAAAA,OAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAAE,sBAAc,EAAC;EAC1CC,IAAI,EAAE;IACL,uBAAuB,EAAE,gBAAgB;IACzC,2BAA2B,EAAE,oBAAoB;IACjD,yBAAyB,EAAE,mBAAmB;IAC9C,kBAAkB,EAAE,WAAW;IAC/B,sBAAsB,EAAE,SAAS;IACjC,sBAAsB,EAAE,eAAe;IACvC,oBAAoB,EAAE,cAAc;IACpC,oBAAoB,EAAE,0BAA0B;IAChD,oBAAoB,EAAE,uCAAuC;IAC7D,2BAA2B,EAAE,oCAAoC;IACjE,sBAAsB,EAAE,uBAAuB;IAC/C,uBAAuB,EAAE,kBAAkB;IAC3C,+BAA+B,EAAE,SAAS;IAC1C,qBAAqB,EAAE,mCAAmC;IAC1D,2BAA2B,EAAE,kBAAkB;IAC/C,sBAAsB,EAAE,gBAAgB;IACxC,wBAAwB,EAAE,0DAA0D;IACpF,sBAAsB,EAAE,gBAAgB;IACxC,0BAA0B,EAAE,oDAAoD;IAChF,sBAAsB,EAAE,sCAAsC;IAC9D,oBAAoB,EAAE,gCAAgC;IACtD,mBAAmB,EAAE,gCAAgC;IACrD,aAAa,EAAE,gBAAgB;IAC/B,wBAAwB,EAAE,iEAAiE;IAC3F,mBAAmB,EAAE,iBAAiB;IACtC,uBAAuB,EAAE,qBAAqB;IAC9C,qBAAqB,EAAE,UAAU;IACjC,mBAAmB,EAAE,aAAa;IAClC,mBAAmB,EAAE,2BAA2B;IAChD,0BAA0B,EAAE,eAAe;IAC3C,mBAAmB,EAAE,mBAAmB;IACxC,mBAAmB,EAAE,mBAAmB;IACxC,oBAAoB,EAAE,kCAAkC;IACxD,uBAAuB,EAAE;EAC1B;AACD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultChartTheme = defaultChartTheme;
|
|
7
|
+
exports.resolveSegmentColors = resolveSegmentColors;
|
|
8
|
+
exports.resolveSeriesColor = resolveSeriesColor;
|
|
9
|
+
exports.segmentKey = segmentKey;
|
|
10
|
+
/**
|
|
11
|
+
* Theme contract (FR-060 to FR-065).
|
|
12
|
+
*
|
|
13
|
+
* A plain value type rather than a dependency. The package declares what it
|
|
14
|
+
* needs and any design system can satisfy it — which is what keeps
|
|
15
|
+
* `@chipmobilesdk/rn-theme` and `react-native-unistyles` out of this package's
|
|
16
|
+
* dependency list entirely. The demo app owns the mapping adapter.
|
|
17
|
+
*
|
|
18
|
+
* Non-colour encodings are first-class here, because meaning must never ride on
|
|
19
|
+
* hue alone (FR-064).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** How the three non-value classes are drawn: texture, never a hue difference. */
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Eight categorical colours per scheme.
|
|
26
|
+
*
|
|
27
|
+
* Chosen for separation in hue *and* lightness, so they stay distinguishable
|
|
28
|
+
* under both common colour-vision deficiencies and a greyscale review. Colour
|
|
29
|
+
* is never the only carrier of meaning regardless — series also differ by
|
|
30
|
+
* legend label and, for lines, by dash pattern.
|
|
31
|
+
*/
|
|
32
|
+
const LIGHT_PALETTE = ['#2563EB', '#D97706', '#059669', '#DB2777', '#7C3AED', '#0891B2', '#B45309', '#4B5563'];
|
|
33
|
+
const DARK_PALETTE = ['#60A5FA', '#FBBF24', '#34D399', '#F472B6', '#A78BFA', '#22D3EE', '#FCD34D', '#9CA3AF'];
|
|
34
|
+
const NON_VALUE_TEXTURES = {
|
|
35
|
+
unknown: 'gap',
|
|
36
|
+
notApplicable: 'hatch',
|
|
37
|
+
withheld: 'lockedHatch'
|
|
38
|
+
};
|
|
39
|
+
function defaultChartTheme(colorScheme = 'light') {
|
|
40
|
+
const dark = colorScheme === 'dark';
|
|
41
|
+
const onSurface = dark ? '#F3F4F6' : '#111827';
|
|
42
|
+
const muted = dark ? '#9CA3AF' : '#6B7280';
|
|
43
|
+
return {
|
|
44
|
+
colorScheme,
|
|
45
|
+
palette: dark ? DARK_PALETTE : LIGHT_PALETTE,
|
|
46
|
+
surface: dark ? '#111827' : '#FFFFFF',
|
|
47
|
+
onSurface,
|
|
48
|
+
axis: dark ? '#4B5563' : '#D1D5DB',
|
|
49
|
+
grid: dark ? '#374151' : '#E5E7EB',
|
|
50
|
+
muted,
|
|
51
|
+
typography: {
|
|
52
|
+
axisLabel: {
|
|
53
|
+
fontSize: 11,
|
|
54
|
+
fontWeight: '400',
|
|
55
|
+
color: muted
|
|
56
|
+
},
|
|
57
|
+
legendLabel: {
|
|
58
|
+
fontSize: 12,
|
|
59
|
+
fontWeight: '500',
|
|
60
|
+
color: onSurface
|
|
61
|
+
},
|
|
62
|
+
valueLabel: {
|
|
63
|
+
fontSize: 13,
|
|
64
|
+
fontWeight: '600',
|
|
65
|
+
color: onSurface
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
spacing: {
|
|
69
|
+
xs: 4,
|
|
70
|
+
sm: 8,
|
|
71
|
+
md: 16
|
|
72
|
+
},
|
|
73
|
+
radius: {
|
|
74
|
+
bar: 3,
|
|
75
|
+
cell: 2
|
|
76
|
+
},
|
|
77
|
+
nonValue: NON_VALUE_TEXTURES,
|
|
78
|
+
heatmapRamp: dark ? ['#1F2937', '#1E3A8A', '#1D4ED8', '#3B82F6', '#93C5FD'] : ['#EFF6FF', '#BFDBFE', '#60A5FA', '#2563EB', '#1E3A8A']
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Assigns a colour to a series: explicit override wins, otherwise the palette
|
|
84
|
+
* cycles by index so the remaining series stay distinguishable (FR-062, FR-063).
|
|
85
|
+
*/
|
|
86
|
+
function resolveSeriesColor(theme, index, override) {
|
|
87
|
+
return override ?? theme.palette[index % theme.palette.length];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Key of one distribution segment: point ids are only unique within a series. */
|
|
91
|
+
function segmentKey(seriesId, pointId) {
|
|
92
|
+
return `${seriesId}/${pointId}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Colours for distribution segments, keyed by `segmentKey`. The single source
|
|
97
|
+
* for both the arcs and the legend, so the two cannot disagree (CHT-02).
|
|
98
|
+
*
|
|
99
|
+
* Segments take palette entries in order across the whole datasource, so one
|
|
100
|
+
* series of four points and four series of one point both give four colours.
|
|
101
|
+
* A point's own `color` wins; a series with a single point is that segment, so
|
|
102
|
+
* the series `color` applies to it.
|
|
103
|
+
*/
|
|
104
|
+
function resolveSegmentColors(datasource, theme) {
|
|
105
|
+
const colors = {};
|
|
106
|
+
let index = 0;
|
|
107
|
+
for (const series of datasource.series) {
|
|
108
|
+
for (const point of series.points) {
|
|
109
|
+
const override = point.color ?? (series.points.length === 1 ? series.color : undefined);
|
|
110
|
+
colors[segmentKey(series.id, point.id)] = resolveSeriesColor(theme, index, override);
|
|
111
|
+
index += 1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return colors;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LIGHT_PALETTE","DARK_PALETTE","NON_VALUE_TEXTURES","unknown","notApplicable","withheld","defaultChartTheme","colorScheme","dark","onSurface","muted","palette","surface","axis","grid","typography","axisLabel","fontSize","fontWeight","color","legendLabel","valueLabel","spacing","xs","sm","md","radius","bar","cell","nonValue","heatmapRamp","resolveSeriesColor","theme","index","override","length","segmentKey","seriesId","pointId","resolveSegmentColors","datasource","colors","series","point","points","undefined","id"],"sourceRoot":"../../../src","sources":["contract/theme.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;;AA0CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,aAAgC,GAAG,CACxC,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAA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
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isKnown = isKnown;
|
|
7
|
+
exports.isWithheld = isWithheld;
|
|
8
|
+
exports.known = known;
|
|
9
|
+
exports.notApplicable = notApplicable;
|
|
10
|
+
exports.participatesInTotals = participatesInTotals;
|
|
11
|
+
exports.sumKnown = sumKnown;
|
|
12
|
+
exports.unknown = unknown;
|
|
13
|
+
exports.withheld = withheld;
|
|
14
|
+
/**
|
|
15
|
+
* Value semantics for @chipmobilesdk/rn-chart.
|
|
16
|
+
*
|
|
17
|
+
* The foundation of the whole contract. Four value classes, carried as a
|
|
18
|
+
* discriminated union with **no numeric field on the three non-value cases**.
|
|
19
|
+
*
|
|
20
|
+
* That shape is deliberate: with a nullable `number`, `value ?? 0` would
|
|
21
|
+
* compile, and turning a gap into a zero is the single most damaging thing a
|
|
22
|
+
* charting library can do to someone's data. Here there is simply no number to
|
|
23
|
+
* read unless the value is known.
|
|
24
|
+
*
|
|
25
|
+
* See specs/007-rn-chart-package/data-model.md §1 (FR-011, FR-012).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** A real observation, including a genuine `0`. */
|
|
29
|
+
|
|
30
|
+
/** We do not know this value. Never rendered as zero, never interpolated. */
|
|
31
|
+
|
|
32
|
+
/** This value does not apply here. Excluded from totals and proportions. */
|
|
33
|
+
|
|
34
|
+
/** Hidden from this viewer: permission, or not enough data to disclose. */
|
|
35
|
+
|
|
36
|
+
const UNKNOWN = {
|
|
37
|
+
kind: 'unknown'
|
|
38
|
+
};
|
|
39
|
+
const NOT_APPLICABLE = {
|
|
40
|
+
kind: 'notApplicable'
|
|
41
|
+
};
|
|
42
|
+
const WITHHELD = {
|
|
43
|
+
kind: 'withheld'
|
|
44
|
+
};
|
|
45
|
+
function known(value) {
|
|
46
|
+
return {
|
|
47
|
+
kind: 'known',
|
|
48
|
+
value
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Note: shadows the `unknown` *type* keyword in value position only. TypeScript
|
|
54
|
+
* keeps type and value namespaces separate, so `x: unknown` still means the
|
|
55
|
+
* type even in modules that import this helper.
|
|
56
|
+
*/
|
|
57
|
+
function unknown() {
|
|
58
|
+
return UNKNOWN;
|
|
59
|
+
}
|
|
60
|
+
function notApplicable() {
|
|
61
|
+
return NOT_APPLICABLE;
|
|
62
|
+
}
|
|
63
|
+
function withheld() {
|
|
64
|
+
return WITHHELD;
|
|
65
|
+
}
|
|
66
|
+
function isKnown(v) {
|
|
67
|
+
return v.kind === 'known';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* True when the value must never reach a rendering, a label, a summary, or an
|
|
72
|
+
* interaction callback (FR-033, FR-053). Withheld values carry no number at
|
|
73
|
+
* all, so this is about intent rather than data hiding.
|
|
74
|
+
*/
|
|
75
|
+
function isWithheld(v) {
|
|
76
|
+
return v.kind === 'withheld';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* True when the point takes part in totals, proportions, and axis domains.
|
|
81
|
+
* `notApplicable` and `withheld` are excluded; excluding either makes a total
|
|
82
|
+
* incomplete (FR-013).
|
|
83
|
+
*/
|
|
84
|
+
function participatesInTotals(v) {
|
|
85
|
+
return v.kind === 'known';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sums known values and reports whether anything was left out (FR-013).
|
|
89
|
+
*
|
|
90
|
+
* `unknown` also excludes and marks the total incomplete: we cannot claim a sum
|
|
91
|
+
* is complete when part of the data is missing.
|
|
92
|
+
*/
|
|
93
|
+
function sumKnown(values) {
|
|
94
|
+
let total = 0;
|
|
95
|
+
let counted = 0;
|
|
96
|
+
let excluded = 0;
|
|
97
|
+
for (const v of values) {
|
|
98
|
+
if (v.kind === 'known') {
|
|
99
|
+
total += v.value;
|
|
100
|
+
counted += 1;
|
|
101
|
+
} else {
|
|
102
|
+
excluded += 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
total,
|
|
107
|
+
incomplete: excluded > 0,
|
|
108
|
+
countedPoints: counted,
|
|
109
|
+
excludedPoints: excluded
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UNKNOWN","kind","NOT_APPLICABLE","WITHHELD","known","value","unknown","notApplicable","withheld","isKnown","v","isWithheld","participatesInTotals","sumKnown","values","total","counted","excluded","incomplete","countedPoints","excludedPoints"],"sourceRoot":"../../../src","sources":["contract/value.ts"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAMA;;AAKA;;AAKA;;AASA,MAAMA,OAAqB,GAAG;EAAEC,IAAI,EAAE;AAAU,CAAC;AACjD,MAAMC,cAAkC,GAAG;EAAED,IAAI,EAAE;AAAgB,CAAC;AACpE,MAAME,QAAuB,GAAG;EAAEF,IAAI,EAAE;AAAW,CAAC;AAE7C,SAASG,KAAKA,CAACC,KAAa,EAAc;EAChD,OAAO;IAAEJ,IAAI,EAAE,OAAO;IAAEI;EAAM,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAA,EAAiB;EACvC,OAAON,OAAO;AACf;AAEO,SAASO,aAAaA,CAAA,EAAuB;EACnD,OAAOL,cAAc;AACtB;AAEO,SAASM,QAAQA,CAAA,EAAkB;EACzC,OAAOL,QAAQ;AAChB;AAEO,SAASM,OAAOA,CAACC,CAAa,EAAmB;EACvD,OAAOA,CAAC,CAACT,IAAI,KAAK,OAAO;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASU,UAAUA,CAACD,CAAa,EAAsB;EAC7D,OAAOA,CAAC,CAACT,IAAI,KAAK,UAAU;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASW,oBAA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