@chipmobilesdk/rn-chart 0.1.1 → 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 -74
  2. package/README.md +337 -314
  3. package/package.json +46 -49
  4. package/skills/sdk-rn-chart/SKILL.md +1 -2
  5. package/src/a11y/summary.ts +170 -177
  6. package/src/contract/datasource.ts +126 -134
  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 -139
  14. package/src/contract/value.ts +121 -125
  15. package/src/geometry/bar.ts +271 -256
  16. package/src/geometry/distribution.ts +197 -200
  17. package/src/geometry/heatmap.ts +189 -195
  18. package/src/geometry/hitTest.ts +117 -120
  19. package/src/geometry/layout.ts +162 -121
  20. package/src/geometry/markers.ts +55 -0
  21. package/src/geometry/path.ts +193 -199
  22. package/src/geometry/progress.ts +223 -204
  23. package/src/geometry/scale.ts +140 -146
  24. package/src/geometry/ticks.ts +145 -153
  25. package/src/geometry/timeSeries.ts +168 -158
  26. package/src/geometry/types.ts +94 -88
  27. package/src/index.ts +158 -176
  28. package/src/react/ChartBoundary.tsx +96 -96
  29. package/src/react/ChartFrame.tsx +583 -620
  30. package/src/react/ChartLegend.tsx +211 -177
  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,74 +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.1.0] - Unreleased
9
-
10
- ### Added
11
-
12
- Initial release. A domain-agnostic charting package for ChipMobileSdk-family
13
- apps.
14
-
15
- - **One datasource contract** across five chart families, with a shared point
16
- envelope and a discriminated `Position` (category, instant, matrix). Families
17
- accepting the same position kind interchange without changing the datasource.
18
- - **Four-way value semantics** — `known` (including a real zero), `unknown`,
19
- `notApplicable`, `withheld` — carried as a discriminated union with no numeric
20
- field on the three non-value cases, so a gap cannot be coerced to zero.
21
- - **Chart families**: `ProgressChart`, `DistributionChart`, `TimeSeriesChart`,
22
- `BarChart`, `HeatmapChart`, plus `ChartLegend`.
23
- - **Seven chart states** per family — loading, empty, ready, error, stale,
24
- no-permission, partial — with per-chart failure containment and an
25
- app-supplied failure-report callback that carries no data values.
26
- - **Interaction callbacks** for point selection, series selection, segment
27
- press, and series visibility. Uncontrolled by default; app-controlled when
28
- the corresponding value prop is supplied. The package never navigates,
29
- fetches, or mutates.
30
- - **Theming** through a `ChartTheme` value type resolved from prop, context, or
31
- a built-in light/dark default. No dependency on `@chipmobilesdk/rn-theme` or
32
- `react-native-unistyles`.
33
- - **Formatting** through app-supplied formatters for axis labels, values,
34
- legend entries, and summaries, with documented locale-neutral defaults.
35
- - **Accessibility**: composed per-chart summaries, state announcements, and
36
- `adjustable` selection traversal for assistive technology.
37
- - **Dataset budgets** (`DATASET_BUDGETS`) with a dev-only, once-per-chart
38
- over-budget warning. Over-budget datasets still render.
39
-
40
- ### Release notes for consuming apps
41
-
42
- What a team adopting this package needs to know and do:
43
-
44
- - **Install two things, not one.** `@chipmobilesdk/rn-chart` and its required
45
- peer `react-native-svg` (>= 15.15), then `pod install` on iOS.
46
- - **No permissions, no manifest changes, no store-declaration changes.** The
47
- package requests nothing and collects nothing. Note that its *no-permission
48
- chart state* is an app-level data-access concept, not an OS permission.
49
- - **Screenshots may need updating** wherever charts change how a screen looks.
50
- No other store metadata is affected.
51
- - **If you chart sensitive data**, read the data-behaviour note in the README
52
- before completing Apple App Privacy or Google Play Data Safety. The package
53
- introduces no collection of its own, but anything your app transmits is yours
54
- to declare.
55
- - **If you render narrative or AI-sourced text near a chart**, moderation and
56
- content obligations are entirely yours — this package ships no free-text
57
- surface.
58
- - **One API habit to adopt**: keep your datasource referentially stable (state
59
- or `useMemo`). Rebuilding it inline every render defeats the package's
60
- memoization, and no library can fix that from the inside.
61
-
62
- ### Notes
63
-
64
- - **Peer dependencies**: `react` >= 19, `react-native` >= 0.85,
65
- `react-native-svg` >= 15.15. No runtime dependencies.
66
- - **Native code**: none is authored in this package. `react-native-svg` is a
67
- native-backed peer; see the README for install and setup.
68
- - **Stability**: the value, datasource, state, error, and interaction contracts
69
- are stable. `ChartTheme`, `LegendEntry`, family-specific props, and the
70
- `DATASET_BUDGETS` values are experimental and may change in a minor release —
71
- see `specs/007-rn-chart-package/contracts/public-api.md` §6.
72
- - **Out of scope, reserved for a future additive minor**: insight/narrative
73
- presentation and composable chart primitives. Neither will change the
74
- 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.