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