@bicharts/chart-host 0.4.0 → 0.4.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.
package/README.md CHANGED
@@ -72,7 +72,7 @@ geography away and leaves nothing to click to change the selection.
72
72
 
73
73
  ```tsx
74
74
  <BicChartGroup columns={columns} rows={rows} point={{ city: "City", state: "StateOrProvince" }}>
75
- <BicChart id="map" code={mapCode} d3={d3} geoKind="na" respondsWith="highlight" />
75
+ <BicChart id="map" code={mapCode} d3={d3} geoKind="north-america" respondsWith="highlight" />
76
76
  <BicChart id="table" code={tableCode} d3={d3} />
77
77
  </BicChartGroup>
78
78
  ```
@@ -137,7 +137,11 @@ createChartHost(el, { code, data, d3, geoKind, geoProvider: geoForKind });
137
137
  createChartHost(el, { code, data, d3, options: { geo } }); // or pass data.geo.json directly
138
138
  ```
139
139
 
140
- Setting `geoKind` with no geometry available warns and draws without a basemap.
140
+ The React `<BicChart>` handles this itself: give it `geoKind` and it fetches the geometry when
141
+ the cache is cold, re-rendering with the basemap when it lands. `await loadGeo(kind)` before
142
+ mounting still works and skips the one-frame pop-in. Outside React, `render()` is synchronous
143
+ by contract, so setting `geoKind` with no geometry available warns and draws without a
144
+ basemap — load or provide geometry first.
141
145
 
142
146
  ## D3 plugins
143
147
 
package/dist/react.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  /*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
2
  import {
3
3
  buildRenderPayload,
4
- createChartHost
4
+ createChartHost,
5
+ geoFromCache,
6
+ loadGeo
5
7
  } from "./chunk-CVJFLLAD.mjs";
6
8
  import "./chunk-A2GMXZP7.mjs";
7
9
 
@@ -70,6 +72,20 @@ function BicChart(props) {
70
72
  rowMapRef.current = built ? built.rowMap : null;
71
73
  const onSelectRef = useRef(onSelect);
72
74
  onSelectRef.current = onSelect;
75
+ const [geoTick, setGeoTick] = useState(0);
76
+ useEffect(() => {
77
+ if (!geoKind || geoFromCache(geoKind)) return;
78
+ let alive = true;
79
+ loadGeo(geoKind).then((g) => {
80
+ if (alive && g) setGeoTick((t) => t + 1);
81
+ });
82
+ return () => {
83
+ alive = false;
84
+ };
85
+ }, [geoKind]);
86
+ useEffect(() => {
87
+ if (geoTick) hostRef.current?.render();
88
+ }, [geoTick]);
73
89
  useLayoutEffect(() => {
74
90
  const el = ref.current;
75
91
  if (!el || !code && !renderFn || !data) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Run a BIC-generated D3 chart in any web host: compiles the generated render() function, applies the shared option defaults, resolves mark clicks (through tooltip overlays), owns the selection affordance, and translates row indices between cross-filtered charts. The same contract the BIC Power BI visual implements, minus Power BI. React bindings at @bicharts/chart-host/react.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -69,6 +69,8 @@
69
69
  "devDependencies": {
70
70
  "@types/react": "^19.2.17",
71
71
  "esbuild": "^0.28.1",
72
+ "react": "^19.2.8",
73
+ "react-dom": "^19.2.8",
72
74
  "typescript": "^5.9.3"
73
75
  },
74
76
  "publishConfig": {