@chipmobilesdk/rn-chart 0.2.0 → 0.2.1

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +126 -115
  2. package/README.md +381 -381
  3. package/package.json +46 -49
  4. package/skills/sdk-rn-chart/SKILL.md +68 -69
  5. package/src/a11y/summary.ts +170 -177
  6. package/src/contract/datasource.ts +126 -136
  7. package/src/contract/errors.ts +129 -133
  8. package/src/contract/format.ts +162 -168
  9. package/src/contract/interaction.ts +70 -71
  10. package/src/contract/marker.ts +75 -75
  11. package/src/contract/props.ts +57 -60
  12. package/src/contract/state.ts +88 -94
  13. package/src/contract/theme.ts +169 -177
  14. package/src/contract/value.ts +121 -125
  15. package/src/geometry/bar.ts +271 -273
  16. package/src/geometry/distribution.ts +197 -203
  17. package/src/geometry/heatmap.ts +189 -195
  18. package/src/geometry/hitTest.ts +117 -120
  19. package/src/geometry/layout.ts +162 -173
  20. package/src/geometry/markers.ts +55 -57
  21. package/src/geometry/path.ts +193 -199
  22. package/src/geometry/progress.ts +223 -230
  23. package/src/geometry/scale.ts +140 -146
  24. package/src/geometry/ticks.ts +145 -153
  25. package/src/geometry/timeSeries.ts +168 -168
  26. package/src/geometry/types.ts +94 -94
  27. package/src/index.ts +158 -176
  28. package/src/react/ChartBoundary.tsx +96 -96
  29. package/src/react/ChartFrame.tsx +583 -622
  30. package/src/react/ChartLegend.tsx +211 -215
  31. package/src/react/ChartThemeProvider.tsx +44 -48
  32. package/src/react/charts.tsx +154 -161
  33. package/src/react/useChartLayout.ts +124 -124
  34. package/src/react/useChartSelection.ts +152 -170
  35. package/src/render/Axis.tsx +120 -122
  36. package/src/render/Marks.tsx +173 -205
  37. package/src/validation/budgets.ts +103 -110
  38. package/src/validation/validateDatasource.ts +174 -174
package/CHANGELOG.md CHANGED
@@ -1,115 +1,126 @@
1
- # Changelog
2
-
3
- All notable changes to `@chipmobilesdk/rn-chart` are documented here.
4
-
5
- The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
- this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [0.2.0] - 2026-11-01
9
-
10
- Three drawing defects on the production path. **No code change is required.**
11
-
12
- ### Fixed
13
-
14
- - **Axis labels are no longer clipped.** The frame handed every builder the
15
- full container, so Y labels (right-aligned left of the plot) were drawn at
16
- negative x and X labels fell below the bottom of the SVG: on a device a bar
17
- or time-series chart showed no value scale and cut-off dates. Builders now
18
- reserve room for their own labels before projecting anything, in one pass.
19
- - **Distribution legends match their segments.** Segments were coloured by
20
- point index while the legend listed series, so a one-series donut of four
21
- segments had four colours and one legend entry; four one-point series all
22
- drew in the first palette colour. Segment colours now come from one resolver
23
- shared by the arcs and the legend, which has one entry per segment. Point
24
- colours also had their own map: they shared the series map, so a point id
25
- equal to a series id overwrote that series' colour, in every family.
26
- - **Reference markers are drawn.** Every builder returned no markers, so
27
- targets, baselines and thresholds reached the accessibility summary only.
28
- Bar and time-series charts now draw them across the plot (with the domain
29
- stretched to include them); progress draws its target on each bar.
30
- - **Progress overshoot stays inside the plot.** It started at the plot's
31
- right edge and was clipped, so 118% looked like 100%. The track is now scaled
32
- so the target sits inside the plot and the excess is visible beyond it.
33
-
34
- - **No phantom axis below zero on all-positive bars.** The domain was padded
35
- past zero on both sides, so a bar chart with no negative value printed a
36
- negative tick (`-5.5`) on top of the `0` label once labels became visible.
37
-
38
- ### Added
39
-
40
- - `DataPoint.color`, a per-segment colour for distribution charts.
41
- - `LegendEntry.pointId`, set on distribution entries.
42
- - `buildLegendEntries(..., family)`: pass `'distribution'` for segment entries.
43
-
44
- ### Changed
45
-
46
- - The plot area of bar and time-series charts is smaller by the space its axis
47
- labels need, and `ResolvedGeometry.plot` reports that inner rectangle.
48
-
49
- ## [0.1.0] - Unreleased
50
-
51
- ### Added
52
-
53
- Initial release. A domain-agnostic charting package for ChipMobileSdk-family
54
- apps.
55
-
56
- - **One datasource contract** across five chart families, with a shared point
57
- envelope and a discriminated `Position` (category, instant, matrix). Families
58
- accepting the same position kind interchange without changing the datasource.
59
- - **Four-way value semantics** — `known` (including a real zero), `unknown`,
60
- `notApplicable`, `withheld` — carried as a discriminated union with no numeric
61
- field on the three non-value cases, so a gap cannot be coerced to zero.
62
- - **Chart families**: `ProgressChart`, `DistributionChart`, `TimeSeriesChart`,
63
- `BarChart`, `HeatmapChart`, plus `ChartLegend`.
64
- - **Seven chart states** per family — loading, empty, ready, error, stale,
65
- no-permission, partial — with per-chart failure containment and an
66
- app-supplied failure-report callback that carries no data values.
67
- - **Interaction callbacks** for point selection, series selection, segment
68
- press, and series visibility. Uncontrolled by default; app-controlled when
69
- the corresponding value prop is supplied. The package never navigates,
70
- fetches, or mutates.
71
- - **Theming** through a `ChartTheme` value type resolved from prop, context, or
72
- a built-in light/dark default. No dependency on `@chipmobilesdk/rn-theme` or
73
- `react-native-unistyles`.
74
- - **Formatting** through app-supplied formatters for axis labels, values,
75
- legend entries, and summaries, with documented locale-neutral defaults.
76
- - **Accessibility**: composed per-chart summaries, state announcements, and
77
- `adjustable` selection traversal for assistive technology.
78
- - **Dataset budgets** (`DATASET_BUDGETS`) with a dev-only, once-per-chart
79
- over-budget warning. Over-budget datasets still render.
80
-
81
- ### Release notes for consuming apps
82
-
83
- What a team adopting this package needs to know and do:
84
-
85
- - **Install two things, not one.** `@chipmobilesdk/rn-chart` and its required
86
- peer `react-native-svg` (>= 15.15), then `pod install` on iOS.
87
- - **No permissions, no manifest changes, no store-declaration changes.** The
88
- package requests nothing and collects nothing. Note that its *no-permission
89
- chart state* is an app-level data-access concept, not an OS permission.
90
- - **Screenshots may need updating** wherever charts change how a screen looks.
91
- No other store metadata is affected.
92
- - **If you chart sensitive data**, read the data-behaviour note in the README
93
- before completing Apple App Privacy or Google Play Data Safety. The package
94
- introduces no collection of its own, but anything your app transmits is yours
95
- to declare.
96
- - **If you render narrative or AI-sourced text near a chart**, moderation and
97
- content obligations are entirely yours — this package ships no free-text
98
- surface.
99
- - **One API habit to adopt**: keep your datasource referentially stable (state
100
- or `useMemo`). Rebuilding it inline every render defeats the package's
101
- memoization, and no library can fix that from the inside.
102
-
103
- ### Notes
104
-
105
- - **Peer dependencies**: `react` >= 19, `react-native` >= 0.85,
106
- `react-native-svg` >= 15.15. No runtime dependencies.
107
- - **Native code**: none is authored in this package. `react-native-svg` is a
108
- native-backed peer; see the README for install and setup.
109
- - **Stability**: the value, datasource, state, error, and interaction contracts
110
- are stable. `ChartTheme`, `LegendEntry`, family-specific props, and the
111
- `DATASET_BUDGETS` values are experimental and may change in a minor release —
112
- see `specs/007-rn-chart-package/contracts/public-api.md` §6.
113
- - **Out of scope, reserved for a future additive minor**: insight/narrative
114
- presentation and composable chart primitives. Neither will change the
115
- datasource, state, or interaction contracts when it lands.
1
+ # @chipmobilesdk/rn-chart
2
+
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Packaging only; no code change. The package no longer declares `engines.node`: a
8
+ React Native package does not run on Node, so the field only produced install
9
+ warnings in apps on another Node version. rn-i18n's command-line tooling does run
10
+ on Node; its README's compatibility table states the version it needs. ([#14](https://github.com/operationd8979/chip-mobile-sdk/pull/14))
11
+
12
+ ## [0.2.0] - 2026-11-01
13
+
14
+ Three drawing defects on the production path. **No code change is required.**
15
+
16
+ ### Fixed
17
+
18
+ - **Axis labels are no longer clipped.** The frame handed every builder the
19
+ full container, so Y labels (right-aligned left of the plot) were drawn at
20
+ negative x and X labels fell below the bottom of the SVG: on a device a bar
21
+ or time-series chart showed no value scale and cut-off dates. Builders now
22
+ reserve room for their own labels before projecting anything, in one pass.
23
+ - **Distribution legends match their segments.** Segments were coloured by
24
+ point index while the legend listed series, so a one-series donut of four
25
+ segments had four colours and one legend entry; four one-point series all
26
+ drew in the first palette colour. Segment colours now come from one resolver
27
+ shared by the arcs and the legend, which has one entry per segment. Point
28
+ colours also had their own map: they shared the series map, so a point id
29
+ equal to a series id overwrote that series' colour, in every family.
30
+ - **Reference markers are drawn.** Every builder returned no markers, so
31
+ targets, baselines and thresholds reached the accessibility summary only.
32
+ Bar and time-series charts now draw them across the plot (with the domain
33
+ stretched to include them); progress draws its target on each bar.
34
+ - **Progress overshoot stays inside the plot.** It started at the plot's
35
+ right edge and was clipped, so 118% looked like 100%. The track is now scaled
36
+ so the target sits inside the plot and the excess is visible beyond it.
37
+
38
+ - **No phantom axis below zero on all-positive bars.** The domain was padded
39
+ past zero on both sides, so a bar chart with no negative value printed a
40
+ negative tick (`-5.5`) on top of the `0` label once labels became visible.
41
+
42
+ ### Added
43
+
44
+ - `DataPoint.color`, a per-segment colour for distribution charts.
45
+ - `LegendEntry.pointId`, set on distribution entries.
46
+ - `buildLegendEntries(..., family)`: pass `'distribution'` for segment entries.
47
+
48
+ ### Changed
49
+
50
+ - The plot area of bar and time-series charts is smaller by the space its axis
51
+ labels need, and `ResolvedGeometry.plot` reports that inner rectangle.
52
+
53
+ ## [0.1.1] - 2026-08-01
54
+
55
+ ### Changed
56
+
57
+ - The package now ships its agent skill (`skills/`), which consuming apps
58
+ copy in with `scripts/sync-sdk-skills.mjs`. No code change.
59
+
60
+ ## [0.1.0] - 2026-08-01
61
+
62
+ ### Added
63
+
64
+ Initial release. A domain-agnostic charting package for ChipMobileSdk-family
65
+ apps.
66
+
67
+ - **One datasource contract** across five chart families, with a shared point
68
+ envelope and a discriminated `Position` (category, instant, matrix). Families
69
+ accepting the same position kind interchange without changing the datasource.
70
+ - **Four-way value semantics** — `known` (including a real zero), `unknown`,
71
+ `notApplicable`, `withheld` — carried as a discriminated union with no numeric
72
+ field on the three non-value cases, so a gap cannot be coerced to zero.
73
+ - **Chart families**: `ProgressChart`, `DistributionChart`, `TimeSeriesChart`,
74
+ `BarChart`, `HeatmapChart`, plus `ChartLegend`.
75
+ - **Seven chart states** per family — loading, empty, ready, error, stale,
76
+ no-permission, partial — with per-chart failure containment and an
77
+ app-supplied failure-report callback that carries no data values.
78
+ - **Interaction callbacks** for point selection, series selection, segment
79
+ press, and series visibility. Uncontrolled by default; app-controlled when
80
+ the corresponding value prop is supplied. The package never navigates,
81
+ fetches, or mutates.
82
+ - **Theming** through a `ChartTheme` value type resolved from prop, context, or
83
+ a built-in light/dark default. No dependency on `@chipmobilesdk/rn-theme` or
84
+ `react-native-unistyles`.
85
+ - **Formatting** through app-supplied formatters for axis labels, values,
86
+ legend entries, and summaries, with documented locale-neutral defaults.
87
+ - **Accessibility**: composed per-chart summaries, state announcements, and
88
+ `adjustable` selection traversal for assistive technology.
89
+ - **Dataset budgets** (`DATASET_BUDGETS`) with a dev-only, once-per-chart
90
+ over-budget warning. Over-budget datasets still render.
91
+
92
+ ### Release notes for consuming apps
93
+
94
+ What a team adopting this package needs to know and do:
95
+
96
+ - **Install two things, not one.** `@chipmobilesdk/rn-chart` and its required
97
+ peer `react-native-svg` (>= 15.15), then `pod install` on iOS.
98
+ - **No permissions, no manifest changes, no store-declaration changes.** The
99
+ package requests nothing and collects nothing. Note that its *no-permission
100
+ chart state* is an app-level data-access concept, not an OS permission.
101
+ - **Screenshots may need updating** wherever charts change how a screen looks.
102
+ No other store metadata is affected.
103
+ - **If you chart sensitive data**, read the data-behaviour note in the README
104
+ before completing Apple App Privacy or Google Play Data Safety. The package
105
+ introduces no collection of its own, but anything your app transmits is yours
106
+ to declare.
107
+ - **If you render narrative or AI-sourced text near a chart**, moderation and
108
+ content obligations are entirely yours — this package ships no free-text
109
+ surface.
110
+ - **One API habit to adopt**: keep your datasource referentially stable (state
111
+ or `useMemo`). Rebuilding it inline every render defeats the package's
112
+ memoization, and no library can fix that from the inside.
113
+
114
+ ### Notes
115
+
116
+ - **Peer dependencies**: `react` >= 19, `react-native` >= 0.85,
117
+ `react-native-svg` >= 15.15. No runtime dependencies.
118
+ - **Native code**: none is authored in this package. `react-native-svg` is a
119
+ native-backed peer; see the README for install and setup.
120
+ - **Stability**: the value, datasource, state, error, and interaction contracts
121
+ are stable. `ChartTheme`, `LegendEntry`, family-specific props, and the
122
+ `DATASET_BUDGETS` values are experimental and may change in a minor release —
123
+ see `specs/007-rn-chart-package/contracts/public-api.md` §6.
124
+ - **Out of scope, reserved for a future additive minor**: insight/narrative
125
+ presentation and composable chart primitives. Neither will change the
126
+ datasource, state, or interaction contracts when it lands.