@bicharts/chart-host 0.6.4 → 0.6.6
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 +28 -0
- package/dist/{chunk-AQMNNUBY.mjs → chunk-ZPWRXCS5.mjs} +634 -494
- package/dist/index.mjs +94 -86
- package/dist/react.mjs +53 -41
- package/dist/types/group.d.ts +88 -0
- package/dist/types/host.d.ts +10 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/react.d.ts +15 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,31 @@ host.setOptions({ colorScaleLow: "#eee" }); // live restyle — never a regene
|
|
|
114
114
|
host.destroy(); // call on unmount
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
+
### Several charts, one selection, without React
|
|
118
|
+
|
|
119
|
+
`createChartGroup` is the group `<BicChartGroup>` wraps: it owns the source table, derives each
|
|
120
|
+
member's payload, and translates every click to **source** row indices, so the row-index hazard
|
|
121
|
+
above is handled the same way in any framework (or none).
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
import { createChartGroup, createChartHost, assembleD3 } from "@bicharts/chart-host";
|
|
125
|
+
|
|
126
|
+
const group = createChartGroup(columns, rows, { point: { city: "City" } });
|
|
127
|
+
const d3all = assembleD3(d3, d3Sankey); // one extensible d3 for every chart
|
|
128
|
+
|
|
129
|
+
function mount(id, el, code, opts = {}) { // opts: { filteredBy, respondsWith }
|
|
130
|
+
const host = createChartHost(el, { code, d3: d3all, data: group.memberPayload(id, opts).payload,
|
|
131
|
+
options: { width: 800, height: 500 } });
|
|
132
|
+
host.render();
|
|
133
|
+
return group.attach(id, host, opts); // .detach() on teardown
|
|
134
|
+
}
|
|
135
|
+
mount("map", mapEl, mapCode, { respondsWith: "highlight" });
|
|
136
|
+
mount("table", tableEl, tableCode);
|
|
137
|
+
|
|
138
|
+
group.onChange(sel => console.log(sel.sourceId, sel.rows)); // SOURCE row indices
|
|
139
|
+
group.clear();
|
|
140
|
+
```
|
|
141
|
+
|
|
117
142
|
## Sizing is yours
|
|
118
143
|
|
|
119
144
|
`width`/`height` have **no defaults**. A chart draws once at whatever it is handed and does not
|
|
@@ -125,6 +150,9 @@ a background or headless tab, where frames are barely produced.
|
|
|
125
150
|
useLayoutEffect(() => setW(ref.current.getBoundingClientRect().width), []);
|
|
126
151
|
```
|
|
127
152
|
|
|
153
|
+
In React, `useMeasuredSize(ref)` from `@bicharts/chart-host/react` does exactly that and follows
|
|
154
|
+
later resizes: give the element its size in CSS and pass what it measures.
|
|
155
|
+
|
|
128
156
|
## Maps
|
|
129
157
|
|
|
130
158
|
Geometry is **not** bundled into the entry — the three assets are ~1.3 MB raw, and a bar chart
|