@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,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reference markers on a value axis: thresholds, baselines and targets drawn
|
|
5
|
+
* as horizontal lines across the plot (FR-008, FR-072).
|
|
6
|
+
*
|
|
7
|
+
* Every builder used to return `markers: []`, so a threshold the app supplied
|
|
8
|
+
* reached the accessibility summary and nowhere else (CHT-03).
|
|
9
|
+
*
|
|
10
|
+
* PURE. No React, no SVG.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { isKnown } from "../contract/value.js";
|
|
14
|
+
import { plotRight } from "./layout.js";
|
|
15
|
+
/** Markers that can be placed on a value axis: those with a known value. */
|
|
16
|
+
export function placeableMarkers(markers) {
|
|
17
|
+
return (markers ?? []).filter(m => isKnown(m.value));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Values the domain must include so every marker lands inside the plot. */
|
|
21
|
+
export function markerDomainValues(markers) {
|
|
22
|
+
return placeableMarkers(markers).map(m => m.value.value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** One line per marker across the plot, plus its label when it has one. */
|
|
26
|
+
export function horizontalMarkers(markers, plot, project) {
|
|
27
|
+
const lines = [];
|
|
28
|
+
const labels = [];
|
|
29
|
+
for (const marker of placeableMarkers(markers)) {
|
|
30
|
+
const y = project(marker.value.value);
|
|
31
|
+
lines.push({
|
|
32
|
+
id: `marker-${marker.id}`,
|
|
33
|
+
d: `M${plot.x},${y}H${plotRight(plot)}`,
|
|
34
|
+
label: marker.label,
|
|
35
|
+
kind: marker.kind
|
|
36
|
+
});
|
|
37
|
+
if (marker.label) {
|
|
38
|
+
labels.push({
|
|
39
|
+
key: `marker-label-${marker.id}`,
|
|
40
|
+
text: marker.label,
|
|
41
|
+
x: plotRight(plot),
|
|
42
|
+
// Above the line, unless that would leave the plot.
|
|
43
|
+
y: y - 4 >= plot.y + 8 ? y - 4 : y + 12,
|
|
44
|
+
anchor: 'end'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
lines,
|
|
50
|
+
labels
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=markers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isKnown","plotRight","placeableMarkers","markers","filter","m","value","markerDomainValues","map","horizontalMarkers","plot","project","lines","labels","marker","y","push","id","d","x","label","kind","key","text","anchor"],"sourceRoot":"../../../src","sources":["geometry/markers.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,sBAAmB;AAC3C,SAASC,SAAS,QAAuB,aAAU;AAKnD;AACA,OAAO,SAASC,gBAAgBA,CAACC,OAA+C,EAAkB;EACjG,OAAO,CAACA,OAAO,IAAI,EA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;AACzB","ignoreList":[]}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SVG path-string builders.
|
|
5
|
+
*
|
|
6
|
+
* This is where the "never bridge a gap" guarantee (FR-012) becomes
|
|
7
|
+
* structural rather than a rule someone has to remember. A missing value does
|
|
8
|
+
* not produce a coordinate — it ends the current subpath. The next known value
|
|
9
|
+
* starts a fresh one with an `M` command. There is physically no line segment
|
|
10
|
+
* spanning the gap, so no amount of downstream carelessness can draw one.
|
|
11
|
+
*
|
|
12
|
+
* Batching into path data is also what keeps element counts flat: one `Path`
|
|
13
|
+
* per series regardless of point count (research.md R2).
|
|
14
|
+
*
|
|
15
|
+
* PURE. No React, no SVG imports — this module emits strings.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** A point that may be absent, mirroring the value contract. */
|
|
19
|
+
|
|
20
|
+
function n(value) {
|
|
21
|
+
// Two decimals is well below sub-pixel visibility and keeps `d` strings
|
|
22
|
+
// short, which matters when they cross the bridge on every data change.
|
|
23
|
+
return Number.isFinite(value) ? value.toFixed(2) : '0';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Polyline through the known points, broken at every gap.
|
|
28
|
+
*
|
|
29
|
+
* `null` entries are missing values. They terminate the current subpath; they
|
|
30
|
+
* are never interpolated, carried forward, or skipped over.
|
|
31
|
+
*/
|
|
32
|
+
export function linePath(points) {
|
|
33
|
+
let d = '';
|
|
34
|
+
let penDown = false;
|
|
35
|
+
for (const p of points) {
|
|
36
|
+
if (p === null) {
|
|
37
|
+
// Lift the pen. The gap stays a gap.
|
|
38
|
+
penDown = false;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!penDown) {
|
|
42
|
+
d += `M${n(p.x)} ${n(p.y)}`;
|
|
43
|
+
penDown = true;
|
|
44
|
+
} else {
|
|
45
|
+
d += `L${n(p.x)} ${n(p.y)}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return d;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Filled area between the polyline and a baseline, broken at gaps in the same
|
|
53
|
+
* way: each contiguous run of known points becomes its own closed shape.
|
|
54
|
+
*/
|
|
55
|
+
export function areaPath(points, baselineY) {
|
|
56
|
+
let d = '';
|
|
57
|
+
let run = [];
|
|
58
|
+
const flush = () => {
|
|
59
|
+
if (run.length === 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
d += `M${n(run[0].x)} ${n(baselineY)}`;
|
|
63
|
+
for (const p of run) {
|
|
64
|
+
d += `L${n(p.x)} ${n(p.y)}`;
|
|
65
|
+
}
|
|
66
|
+
d += `L${n(run[run.length - 1].x)} ${n(baselineY)}Z`;
|
|
67
|
+
run = [];
|
|
68
|
+
};
|
|
69
|
+
for (const p of points) {
|
|
70
|
+
if (p === null) {
|
|
71
|
+
flush();
|
|
72
|
+
} else {
|
|
73
|
+
run.push(p);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
flush();
|
|
77
|
+
return d;
|
|
78
|
+
}
|
|
79
|
+
/** One rectangle as a subpath, with optional corner rounding. */
|
|
80
|
+
export function rectSubpath(r) {
|
|
81
|
+
const radius = Math.min(r.radius ?? 0, r.width / 2, Math.abs(r.height) / 2);
|
|
82
|
+
if (radius <= 0) {
|
|
83
|
+
return `M${n(r.x)} ${n(r.y)}` + `h${n(r.width)}v${n(r.height)}h${n(-r.width)}Z`;
|
|
84
|
+
}
|
|
85
|
+
const {
|
|
86
|
+
x,
|
|
87
|
+
y,
|
|
88
|
+
width: w,
|
|
89
|
+
height: h
|
|
90
|
+
} = r;
|
|
91
|
+
return `M${n(x + radius)} ${n(y)}` + `h${n(w - radius * 2)}` + `a${n(radius)} ${n(radius)} 0 0 1 ${n(radius)} ${n(radius)}` + `v${n(h - radius * 2)}` + `a${n(radius)} ${n(radius)} 0 0 1 ${n(-radius)} ${n(radius)}` + `h${n(-(w - radius * 2))}` + `a${n(radius)} ${n(radius)} 0 0 1 ${n(-radius)} ${n(-radius)}` + `v${n(-(h - radius * 2))}` + `a${n(radius)} ${n(radius)} 0 0 1 ${n(radius)} ${n(-radius)}Z`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Many rectangles batched into one path — how bars and heatmap cells stay at
|
|
96
|
+
* one element per series or per intensity bucket.
|
|
97
|
+
*/
|
|
98
|
+
export function rectBatchPath(rects) {
|
|
99
|
+
let d = '';
|
|
100
|
+
for (const r of rects) {
|
|
101
|
+
d += rectSubpath(r);
|
|
102
|
+
}
|
|
103
|
+
return d;
|
|
104
|
+
}
|
|
105
|
+
function polar(cx, cy, r, angle) {
|
|
106
|
+
// Offset by -90 degrees so 0 radians is 12 o'clock, which is where users
|
|
107
|
+
// expect a donut to start.
|
|
108
|
+
const a = angle - Math.PI / 2;
|
|
109
|
+
return {
|
|
110
|
+
x: cx + r * Math.cos(a),
|
|
111
|
+
y: cy + r * Math.sin(a)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Donut or pie segment. An inner radius of 0 yields a pie wedge.
|
|
117
|
+
*
|
|
118
|
+
* A full-circle segment is drawn as two half-arcs, because SVG cannot express
|
|
119
|
+
* a 360-degree arc in a single command — start and end would coincide and
|
|
120
|
+
* nothing would be drawn.
|
|
121
|
+
*/
|
|
122
|
+
export function arcPath(spec) {
|
|
123
|
+
const {
|
|
124
|
+
cx,
|
|
125
|
+
cy,
|
|
126
|
+
outerRadius: ro,
|
|
127
|
+
innerRadius: ri
|
|
128
|
+
} = spec;
|
|
129
|
+
const sweep = spec.endAngle - spec.startAngle;
|
|
130
|
+
const full = Math.abs(sweep) >= Math.PI * 2 - 1e-9;
|
|
131
|
+
if (full) {
|
|
132
|
+
const mid = spec.startAngle + Math.PI;
|
|
133
|
+
return arcPath({
|
|
134
|
+
...spec,
|
|
135
|
+
endAngle: mid
|
|
136
|
+
}) + arcPath({
|
|
137
|
+
...spec,
|
|
138
|
+
startAngle: mid,
|
|
139
|
+
endAngle: spec.startAngle + Math.PI * 2
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const largeArc = Math.abs(sweep) > Math.PI ? 1 : 0;
|
|
143
|
+
const o0 = polar(cx, cy, ro, spec.startAngle);
|
|
144
|
+
const o1 = polar(cx, cy, ro, spec.endAngle);
|
|
145
|
+
if (ri <= 0) {
|
|
146
|
+
return `M${n(cx)} ${n(cy)}` + `L${n(o0.x)} ${n(o0.y)}` + `A${n(ro)} ${n(ro)} 0 ${largeArc} 1 ${n(o1.x)} ${n(o1.y)}Z`;
|
|
147
|
+
}
|
|
148
|
+
const i1 = polar(cx, cy, ri, spec.endAngle);
|
|
149
|
+
const i0 = polar(cx, cy, ri, spec.startAngle);
|
|
150
|
+
return `M${n(o0.x)} ${n(o0.y)}` + `A${n(ro)} ${n(ro)} 0 ${largeArc} 1 ${n(o1.x)} ${n(o1.y)}` + `L${n(i1.x)} ${n(i1.y)}` + `A${n(ri)} ${n(ri)} 0 ${largeArc} 0 ${n(i0.x)} ${n(i0.y)}Z`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Straight line, for axes, baselines, and threshold markers. */
|
|
154
|
+
export function linearSegment(from, to) {
|
|
155
|
+
return `M${n(from.x)} ${n(from.y)}L${n(to.x)} ${n(to.y)}`;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["n","value","Number","isFinite","toFixed","linePath","points","d","penDown","p","x","y","areaPath","baselineY","run","flush","length","push","rectSubpath","r","radius","Math","min","width","abs","height","w","h","rectBatchPath","rects","polar","cx","cy","angle","a","PI","cos","sin","arcPath","spec","outerRadius","ro","innerRadius","ri","sweep","endAngle","startAngle","full","mid","largeArc","o0","o1","i1","i0","linearSegment","from","to"],"sourceRoot":"../../../src","sources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AC,CAAC2C,EAAE,CAAC,MAAMM,QAAQ,MAAMjD,CAAC,CAACqD,EAAE,CAAC3C,CAAC,CAAC,IAAIV,CAAC,CAACqD,EAAE,CAAC1C,CAAC,CAAC,GAAG;AAE7D;;AAEA;AACA,OAAO,SAAS2C,aAAaA,CAACC,IAAQ,EAAEC,EAAM,EAAU;EACvD,OAAO,IAAIxD,CAAC,CAACuD,IAAI,CAAC7C,CAAC,CAAC,IAAIV,CAAC,CAACuD,IAAI,CAAC5C,CAAC,CAAC,IAAIX,CAAC,CAACwD,EAAE,CAAC9C,CAAC,CAAC,IAAIV,CAAC,CAACwD,EAAE,CAAC7C,CAAC,CAAC,EAAE;AAC1D","ignoreList":[]}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Progress geometry: current value against an optional target.
|
|
5
|
+
*
|
|
6
|
+
* The rule that matters (FR-021, FR-022): with no usable target there is **no
|
|
7
|
+
* proportion**. The chart shows the current value and nothing else. And a value
|
|
8
|
+
* beyond its target renders as overshoot rather than a clamped full bar that
|
|
9
|
+
* hides the excess.
|
|
10
|
+
*
|
|
11
|
+
* PURE. No React, no SVG.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { findTarget, readProgress } from "../contract/marker.js";
|
|
15
|
+
import { isKnown, isWithheld } from "../contract/value.js";
|
|
16
|
+
import { plotBottom, plotRight } from "./layout.js";
|
|
17
|
+
import { rectSubpath } from "./path.js";
|
|
18
|
+
/** How far past the target an overshoot bar is allowed to extend visually. */
|
|
19
|
+
const OVERSHOOT_DISPLAY_CAP = 1.25;
|
|
20
|
+
export function buildProgressGeometry(datasource, input, options = {}) {
|
|
21
|
+
const {
|
|
22
|
+
plot
|
|
23
|
+
} = input;
|
|
24
|
+
const metrics = datasource.series.flatMap(series => series.points.map(point => ({
|
|
25
|
+
series,
|
|
26
|
+
point
|
|
27
|
+
})));
|
|
28
|
+
if (metrics.length === 0 || plot.width <= 0) {
|
|
29
|
+
return {
|
|
30
|
+
plot,
|
|
31
|
+
paths: [],
|
|
32
|
+
markers: [],
|
|
33
|
+
labels: [],
|
|
34
|
+
xTicks: [],
|
|
35
|
+
yTicks: [],
|
|
36
|
+
hitRegions: [],
|
|
37
|
+
incomplete: false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const readings = metrics.map(({
|
|
41
|
+
point
|
|
42
|
+
}) => readProgress(point.value, findTarget(datasource.markers, point.id) ?? findTarget(datasource.markers)));
|
|
43
|
+
|
|
44
|
+
// The track spans 0..displayMax of the target, shared by every row so their
|
|
45
|
+
// targets line up. With an overshoot the target sits inside the plot and the
|
|
46
|
+
// excess is drawn to its right — previously the target was the plot's right
|
|
47
|
+
// edge, so overshoot started there and was clipped by the SVG (CHT-03).
|
|
48
|
+
const displayMax = readings.reduce((max, r) => r.proportion === undefined ? max : Math.max(max, Math.min(r.proportion, OVERSHOOT_DISPLAY_CAP)), 1);
|
|
49
|
+
const unit = plot.width / displayMax;
|
|
50
|
+
const targetX = plot.x + unit;
|
|
51
|
+
const rowHeight = plot.height / metrics.length;
|
|
52
|
+
const barHeight = Math.min(rowHeight * 0.45, 24);
|
|
53
|
+
const radius = options.trackRadius ?? barHeight / 2;
|
|
54
|
+
const paths = [];
|
|
55
|
+
const labels = [];
|
|
56
|
+
const hitRegions = [];
|
|
57
|
+
const markers = [];
|
|
58
|
+
let incomplete = false;
|
|
59
|
+
metrics.forEach(({
|
|
60
|
+
series,
|
|
61
|
+
point
|
|
62
|
+
}, index) => {
|
|
63
|
+
const rowY = plot.y + index * rowHeight + (rowHeight - barHeight) / 2;
|
|
64
|
+
const reading = readings[index];
|
|
65
|
+
|
|
66
|
+
// Track: the full width, always drawn, so an empty metric still reads as
|
|
67
|
+
// a metric rather than as blank space.
|
|
68
|
+
paths.push({
|
|
69
|
+
key: `track-${series.id}-${point.id}`,
|
|
70
|
+
seriesId: series.id,
|
|
71
|
+
d: rectSubpath({
|
|
72
|
+
x: plot.x,
|
|
73
|
+
y: rowY,
|
|
74
|
+
width: plot.width,
|
|
75
|
+
height: barHeight,
|
|
76
|
+
radius
|
|
77
|
+
}),
|
|
78
|
+
color: input.seriesColors[series.id],
|
|
79
|
+
pattern: 'solid',
|
|
80
|
+
filled: true,
|
|
81
|
+
opacity: 0.15
|
|
82
|
+
});
|
|
83
|
+
if (!isKnown(point.value)) {
|
|
84
|
+
incomplete = true;
|
|
85
|
+
// No fill at all, and a texture rather than a zero-length bar — a gap
|
|
86
|
+
// must not look like "none of the target achieved".
|
|
87
|
+
paths.push({
|
|
88
|
+
key: `nonvalue-${series.id}-${point.id}`,
|
|
89
|
+
seriesId: series.id,
|
|
90
|
+
d: rectSubpath({
|
|
91
|
+
x: plot.x,
|
|
92
|
+
y: rowY,
|
|
93
|
+
width: plot.width,
|
|
94
|
+
height: barHeight,
|
|
95
|
+
radius
|
|
96
|
+
}),
|
|
97
|
+
color: input.seriesColors[series.id],
|
|
98
|
+
pattern: 'solid',
|
|
99
|
+
filled: true,
|
|
100
|
+
texture: input.nonValueTextures[point.value.kind],
|
|
101
|
+
opacity: 0.5
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
const proportion = reading.proportion;
|
|
105
|
+
// With no usable target there is no proportion to draw, so the fill
|
|
106
|
+
// shows the value's presence rather than a fabricated percentage.
|
|
107
|
+
const fillFraction = proportion === undefined ? 1 : Math.min(proportion, OVERSHOOT_DISPLAY_CAP);
|
|
108
|
+
paths.push({
|
|
109
|
+
key: `fill-${series.id}-${point.id}`,
|
|
110
|
+
seriesId: series.id,
|
|
111
|
+
d: rectSubpath({
|
|
112
|
+
x: plot.x,
|
|
113
|
+
y: rowY,
|
|
114
|
+
width: Math.max(0, unit * Math.min(fillFraction, 1)),
|
|
115
|
+
height: barHeight,
|
|
116
|
+
radius
|
|
117
|
+
}),
|
|
118
|
+
color: input.seriesColors[series.id],
|
|
119
|
+
pattern: 'solid',
|
|
120
|
+
filled: true
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Overshoot is drawn beyond the target line rather than clamped away,
|
|
124
|
+
// so exceeding a goal is visible instead of indistinguishable from
|
|
125
|
+
// exactly meeting it.
|
|
126
|
+
if (reading.overshoot && proportion !== undefined) {
|
|
127
|
+
const overshootWidth = unit * (Math.min(proportion, OVERSHOOT_DISPLAY_CAP) - 1);
|
|
128
|
+
paths.push({
|
|
129
|
+
key: `overshoot-${series.id}-${point.id}`,
|
|
130
|
+
seriesId: series.id,
|
|
131
|
+
d: rectSubpath({
|
|
132
|
+
x: targetX,
|
|
133
|
+
y: rowY + barHeight * 0.2,
|
|
134
|
+
width: Math.max(0, overshootWidth),
|
|
135
|
+
height: barHeight * 0.6,
|
|
136
|
+
radius: radius / 2
|
|
137
|
+
}),
|
|
138
|
+
color: input.seriesColors[series.id],
|
|
139
|
+
pattern: 'dashed',
|
|
140
|
+
filled: true,
|
|
141
|
+
opacity: 0.7
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// The target itself, across this row's bar (FR-022, FR-072).
|
|
147
|
+
if (reading.proportion !== undefined && reading.target) {
|
|
148
|
+
markers.push({
|
|
149
|
+
id: `target-${series.id}-${point.id}`,
|
|
150
|
+
d: `M${targetX},${Math.max(plot.y, rowY - 3)}V${Math.min(plotBottom(plot), rowY + barHeight + 3)}`,
|
|
151
|
+
label: reading.target.label,
|
|
152
|
+
kind: 'target'
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const valueText = isKnown(point.value) ? input.formatValue(point.value.value) : '';
|
|
156
|
+
// Only append a percentage when one is real.
|
|
157
|
+
const proportionText = reading.proportion === undefined ? '' : ` (${Math.round(reading.proportion * 100)}%)`;
|
|
158
|
+
labels.push({
|
|
159
|
+
key: `label-${series.id}-${point.id}`,
|
|
160
|
+
text: input.formatCategory(point.position.kind === 'category' ? point.position.category : series.label),
|
|
161
|
+
x: plot.x,
|
|
162
|
+
y: rowY - 4,
|
|
163
|
+
anchor: 'start'
|
|
164
|
+
});
|
|
165
|
+
if (valueText) {
|
|
166
|
+
labels.push({
|
|
167
|
+
key: `value-${series.id}-${point.id}`,
|
|
168
|
+
text: `${valueText}${proportionText}`,
|
|
169
|
+
x: plotRight(plot),
|
|
170
|
+
y: rowY - 4,
|
|
171
|
+
anchor: 'end'
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
hitRegions.push({
|
|
175
|
+
seriesId: series.id,
|
|
176
|
+
pointId: point.id,
|
|
177
|
+
x: plot.x + plot.width / 2,
|
|
178
|
+
y: rowY + barHeight / 2,
|
|
179
|
+
bounds: {
|
|
180
|
+
x: plot.x,
|
|
181
|
+
y: rowY,
|
|
182
|
+
width: plot.width,
|
|
183
|
+
height: barHeight
|
|
184
|
+
},
|
|
185
|
+
selectable: !isWithheld(point.value)
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
plot,
|
|
190
|
+
paths,
|
|
191
|
+
markers,
|
|
192
|
+
labels,
|
|
193
|
+
xTicks: [],
|
|
194
|
+
yTicks: [],
|
|
195
|
+
hitRegions,
|
|
196
|
+
incomplete
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["findTarget","readProgress","isKnown","isWithheld","plotBottom","plotRight","rectSubpath","OVERSHOOT_DISPLAY_CAP","buildProgressGeometry","datasource","input","options","plot","metrics","series","flatMap","points","map","point","length","width","paths","markers","labels","xTicks","yTicks","hitRegions","incomplete","readings","value","id","displayMax","reduce","max","r","proportion","undefined","Math","min","unit","targetX","x","rowHeight","height","barHeight","radius","trackRadius","forEach","index","rowY","y","reading","push","key","seriesId","d","color","seriesColors","pattern","filled","opacity","texture","nonValueTextures","kind","fillFraction","overshoot","overshootWidth","target","label","valueText","formatValue","proportionText","round","text","formatCategory","position","category","anchor","pointId","bounds","selectable"],"sourceRoot":"../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C,EAAED,IAAI,GAAG,CAAC;MACX4B,MAAM,EAAE;IACT,CAAC,CAAC;IAEF,IAAIR,SAAS,EAAE;MACd9C,MAAM,CAAC6B,IAAI,CAAC;QACXC,GAAG,EAAE,SAASvC,MAAM,CAACgB,EAAE,IAAIZ,KAAK,CAACY,EAAE,EAAE;QACrC2C,IAAI,EAAE,GAAGJ,SAAS,GAAGE,cAAc,EAAE;QACrC9B,CAAC,EAAEpC,SAAS,CAACO,IAAI,CAAC;QAClBsC,CAAC,EAAED,IAAI,GAAG,CAAC;QACX4B,MAAM,EAAE;MACT,CAAC,CAAC;IACH;IAEAnD,UAAU,CAAC0B,IAAI,CAAC;MACfE,QAAQ,EAAExC,MAAM,CAACgB,EAAE;MACnBgD,OAAO,EAAE5D,KAAK,CAACY,EAAE;MACjBW,CAAC,EAAE7B,IAAI,CAAC6B,CAAC,GAAG7B,IAAI,CAACQ,KAAK,GAAG,CAAC;MAC1B8B,CAAC,EAAED,IAAI,GAAGL,SAAS,GAAG,CAAC;MACvBmC,MAAM,EAAE;QAAEtC,CAAC,EAAE7B,IAAI,CAAC6B,CAAC;QAAES,CAAC,EAAED,IAAI;QAAE7B,KAAK,EAAER,IAAI,CAACQ,KAAK;QAAEuB,MAAM,EAAEC;MAAU,CAAC;MACpEoC,UAAU,EAAE,CAAC7E,UAAU,CAACe,KAAK,CAACW,KAAK;IACpC,CAAC,CAAC;EACH,CAAC,CAAC;EAEF,OAAO;IACNjB,IAAI;IACJS,KAAK;IACLC,OAAO;IACPC,MAAM;IACNC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE,EAAE;IACVC,UAAU;IACVC;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scales: domain values to pixel positions.
|
|
5
|
+
*
|
|
6
|
+
* PURE. No React, no SVG — enforced by the ESLint override in `.eslintrc.js`
|
|
7
|
+
* and by geometryPurity.test.ts.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Nudges a zero-width domain outward so an all-identical dataset still gets a
|
|
12
|
+
* usable axis. Without this the projection divides by zero and every point
|
|
13
|
+
* lands on the same pixel — or on NaN.
|
|
14
|
+
*/
|
|
15
|
+
export function widenDegenerateDomain(domain) {
|
|
16
|
+
if (domain.max > domain.min) {
|
|
17
|
+
return domain;
|
|
18
|
+
}
|
|
19
|
+
const value = domain.min;
|
|
20
|
+
// Scale the padding to the magnitude so large values do not get a
|
|
21
|
+
// meaninglessly tiny window, and zero still gets a sensible one.
|
|
22
|
+
const pad = value === 0 ? 1 : Math.abs(value) * 0.5;
|
|
23
|
+
return {
|
|
24
|
+
min: value - pad,
|
|
25
|
+
max: value + pad
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function linearScale(domain, rangePx) {
|
|
29
|
+
const safeDomain = widenDegenerateDomain(domain);
|
|
30
|
+
const domainSpan = safeDomain.max - safeDomain.min;
|
|
31
|
+
const pxSpan = rangePx.max - rangePx.min;
|
|
32
|
+
return {
|
|
33
|
+
domain: safeDomain,
|
|
34
|
+
rangePx,
|
|
35
|
+
project: value => rangePx.min + (value - safeDomain.min) / domainSpan * pxSpan,
|
|
36
|
+
invert: px => safeDomain.min + (px - rangePx.min) / pxSpan * domainSpan
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Discrete positions for category axes.
|
|
41
|
+
*
|
|
42
|
+
* `padding` is the fraction of each step left as gap, so 0.2 means bars occupy
|
|
43
|
+
* 80% of their slot.
|
|
44
|
+
*/
|
|
45
|
+
export function bandScale(categories, rangePx, padding = 0.2) {
|
|
46
|
+
const count = Math.max(categories.length, 1);
|
|
47
|
+
const pxSpan = rangePx.max - rangePx.min;
|
|
48
|
+
const step = pxSpan / count;
|
|
49
|
+
const bandWidth = step * (1 - padding);
|
|
50
|
+
const offset = (step - bandWidth) / 2;
|
|
51
|
+
const indexOf = new Map();
|
|
52
|
+
categories.forEach((c, i) => {
|
|
53
|
+
if (!indexOf.has(c)) {
|
|
54
|
+
indexOf.set(c, i);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const project = category => {
|
|
58
|
+
const i = indexOf.get(category);
|
|
59
|
+
return i === undefined ? undefined : rangePx.min + i * step + offset;
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
categories,
|
|
63
|
+
bandWidth,
|
|
64
|
+
step,
|
|
65
|
+
project,
|
|
66
|
+
centerOf: category => {
|
|
67
|
+
const start = project(category);
|
|
68
|
+
return start === undefined ? undefined : start + bandWidth / 2;
|
|
69
|
+
},
|
|
70
|
+
invert: px => {
|
|
71
|
+
const i = Math.floor((px - rangePx.min) / step);
|
|
72
|
+
return i >= 0 && i < categories.length ? categories[i] : undefined;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Time is just a linear scale over epoch milliseconds. Kept as a named
|
|
79
|
+
* function so call sites read clearly and so tick generation can branch on it.
|
|
80
|
+
*/
|
|
81
|
+
export function timeScale(domain, rangePx) {
|
|
82
|
+
return linearScale(domain, rangePx);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Domain from known values, padded so marks do not touch the plot edges.
|
|
87
|
+
*
|
|
88
|
+
* `includeZero` matters for bar charts: a bar's length is only meaningful when
|
|
89
|
+
* measured from zero. Time-series charts leave it off so a narrow band of
|
|
90
|
+
* values stays legible.
|
|
91
|
+
*/
|
|
92
|
+
export function domainFrom(values, options = {}) {
|
|
93
|
+
if (values.length === 0) {
|
|
94
|
+
return {
|
|
95
|
+
min: 0,
|
|
96
|
+
max: 1
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
let min = values[0];
|
|
100
|
+
let max = values[0];
|
|
101
|
+
for (const v of values) {
|
|
102
|
+
if (v < min) {
|
|
103
|
+
min = v;
|
|
104
|
+
}
|
|
105
|
+
if (v > max) {
|
|
106
|
+
max = v;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (options.includeZero) {
|
|
110
|
+
min = Math.min(min, 0);
|
|
111
|
+
max = Math.max(max, 0);
|
|
112
|
+
}
|
|
113
|
+
const pad = (max - min) * (options.padFraction ?? 0);
|
|
114
|
+
return {
|
|
115
|
+
min: min - pad,
|
|
116
|
+
max: max + pad
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["widenDegenerateDomain","domain","max","min","value","pad","Math","abs","linearScale","rangePx","safeDomain","domainSpan","pxSpan","project","invert","px","bandScale","categories","padding","count","length","step","bandWidth","offset","indexOf","Map","forEach","c","i","has","set","category","get","undefined","centerOf","start","floor","timeScale","domainFrom","values","options","v","includeZero","padFraction"],"sourceRoot":"../../../src","sources":["geometry/scale.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqBA,CAACC,MAAa,EAAS;EAC3D,IAAIA,MAAM,CAACC,GAAG,GAAGD,MAAM,CAACE,GAAG,EAAE;IAC5B,OAAOF,MAAM;EACd;EACA,MAAMG,KAAK,GAAGH,MAAM,CAACE,GAAG;EACxB;EACA;EACA,MAAME,GAAG,GAAGD,KAAK,KAAK,CAAC,GAAG,CAAC,GAAGE,IAAI,CAACC,GAAG,CAACH,KAAK,CAAC,GAAG,GAAG;EACnD,OAAO;IAAED,GAAG,EAAEC,KAAK,GAAGC,GAAG;IAAEH,GAAG,EAAEE,KAAK,GAAGC;EAAI,CAAC;AAC9C;AAEA,OAAO,SAASG,WAAWA,CAACP,MAAa,EAAEQ,OAAc,EAAe;EACvE,MAAMC,UAAU,GAAGV,qBAAqB,CAACC,MAAM,CAAC;EAChD,MAAMU,UAAU,GAAGD,UAAU,CAACR,GAAG,GAAGQ,U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