@bicharts/chart-host 0.1.13 → 0.2.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/README.md CHANGED
@@ -131,6 +131,43 @@ visual — override them if you want a different look:
131
131
  .bic-chart-host.lch-has-selection .d3-mark:not(.lch-mark-selected) { opacity: var(--lch-dim-opacity); }
132
132
  ```
133
133
 
134
+ ## Architecture — three layers, and why it matters if you contribute
135
+
136
+ Read this before adding code. The package has **three** concerns, and they are independent.
137
+ Most well-meaning changes that damage it do so by collapsing two of them.
138
+
139
+ | layer | knows about | must **not** know about |
140
+ | --- | --- | --- |
141
+ | **1 · Core** | rows, marks as a *concept*, selection state, the cross-filter protocol, option resolution | any charting library, any host |
142
+ | **2 · Renderer adapter** | how *one* library expresses a binding, and where its marks live | the host it is running in |
143
+ | **3 · Host glue** | one host's lifecycle, identity model and settings | a library's internals |
144
+
145
+ Layer 3 is **not in this package** — it is the integrator's. `createChartHost` is the glue for a
146
+ plain web page; the BIC Power BI visual has its own, because a report host's lifecycle is
147
+ genuinely different. That separation is deliberate: merging them would drag host concepts into a
148
+ package whose entire value is not having them.
149
+
150
+ **Layer 2 is the one that is easy to get wrong**, because today only one adapter exists (D3) and
151
+ its assumptions are easy to mistake for universal truths. They are not. Two examples from charts
152
+ BIC already generates:
153
+
154
+ - **Marks are not always DOM elements.** D3 tags them in the DOM (`.d3-mark` + `data-row-idx`).
155
+ Other libraries carry the row binding in their *data model* instead, on the trace or point.
156
+ An abstraction phrased as `querySelectorAll(markClass)` is D3's implementation wearing the
157
+ costume of an interface.
158
+ - **A renderer may support no interaction at all.** Some chart types render to a raster image —
159
+ no DOM, no marks, nothing to hit-test. A null adapter has to be legal.
160
+
161
+ So: if you are adding support for another charting library, you should be implementing layer 2
162
+ and touching nothing else. If your change needs edits in the core to make one library work, the
163
+ seam is in the wrong place — please open an issue rather than widening the core.
164
+
165
+ **Known wart, and it is ours, not yours.** `contract.ts` currently mixes layers 1 and 2:
166
+ `MARK_CLASS` (`"d3-mark"`) and `ROW_IDX_ATTR` are D3's binding mechanism, while
167
+ `XFILTER_REFRESH_EVENT`, the `lch-*` selection classes and `DIM_OPACITY_VAR` are genuinely
168
+ renderer-neutral. The names are historical. Do not take the file's current shape as licence to
169
+ add more renderer-specific constants to it.
170
+
134
171
  ## Versioning
135
172
 
136
173
  `HOST_CONTRACT_VERSION` is the grammar version (mark classes, container slots, the cross-filter
@@ -6,4 +6,3 @@ var US_STATES = { "type": "FeatureCollection", "features": [{ "type": "Feature",
6
6
  export {
7
7
  US_STATES
8
8
  };
9
- //# sourceMappingURL=chunk-NWID6YOP.mjs.map
@@ -67,4 +67,3 @@ export {
67
67
  NA_LAT_MAX,
68
68
  clipFeatureToLat
69
69
  };
70
- //# sourceMappingURL=chunk-X7PWWEGM.mjs.map
@@ -6,4 +6,3 @@ var WORLD_110M = { "type": "FeatureCollection", "features": [{ "type": "Feature"
6
6
  export {
7
7
  WORLD_110M
8
8
  };
9
- //# sourceMappingURL=chunk-23GNNTXQ.mjs.map