@bicharts/chart-host 0.6.10 → 0.6.12
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 +8 -3
- package/dist/{chunk-M7KJHGZS.mjs → chunk-5IE7AWZY.mjs} +5 -4
- package/dist/index.mjs +3 -1
- package/dist/react.mjs +1 -1
- package/dist/types/host.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,12 +178,17 @@ basemap — load or provide geometry first.
|
|
|
178
178
|
## D3 plugins
|
|
179
179
|
|
|
180
180
|
Some charts call `d3.sankey()`, `d3.hexbin()` or the voronoi family. Those are separate packages
|
|
181
|
-
that **attach onto the d3 object** — install them and
|
|
181
|
+
that **attach onto the d3 object** — install them and pass the host *one* d3 that carries them.
|
|
182
|
+
`import * as d3` is a module namespace, which is frozen, so assigning a plugin onto it throws;
|
|
183
|
+
`assembleD3` builds a plain copy instead:
|
|
182
184
|
|
|
183
185
|
```js
|
|
184
|
-
import * as
|
|
186
|
+
import * as d3base from "d3";
|
|
185
187
|
import { sankey, sankeyLinkHorizontal } from "d3-sankey";
|
|
186
|
-
|
|
188
|
+
import { assembleD3 } from "@bicharts/chart-host";
|
|
189
|
+
|
|
190
|
+
const d3 = assembleD3(d3base, { sankey, sankeyLinkHorizontal });
|
|
191
|
+
createChartHost(el, { code, data, d3 });
|
|
187
192
|
```
|
|
188
193
|
|
|
189
194
|
The integration contract returned by `generate_chart` names exactly which ones *your* chart
|
|
@@ -3334,7 +3334,7 @@ var parseRowIdxs = (s) => (s || "").split(",").map((x2) => parseInt(x2, 10)).fil
|
|
|
3334
3334
|
function assembleD3(base, ...plugins) {
|
|
3335
3335
|
return Object.assign({}, base, ...plugins);
|
|
3336
3336
|
}
|
|
3337
|
-
var D3_PLUGIN_PACKAGES = {
|
|
3337
|
+
var D3_PLUGIN_PACKAGES = Object.freeze({
|
|
3338
3338
|
sankey: "d3-sankey",
|
|
3339
3339
|
sankeyLinkHorizontal: "d3-sankey",
|
|
3340
3340
|
sankeyJustify: "d3-sankey",
|
|
@@ -3360,7 +3360,7 @@ var D3_PLUGIN_PACKAGES = {
|
|
|
3360
3360
|
// host INSTALL for this code to run" and not "which package exports this symbol". For
|
|
3361
3361
|
// code that calls the helper, the answer is the library the helper reaches for.
|
|
3362
3362
|
llmMermaid: "mermaid"
|
|
3363
|
-
};
|
|
3363
|
+
});
|
|
3364
3364
|
function requiredD3Plugins(code) {
|
|
3365
3365
|
const out = /* @__PURE__ */ new Set();
|
|
3366
3366
|
const body = stripJsComments(String(code || ""));
|
|
@@ -3384,7 +3384,7 @@ function explainRenderFailure(err, d3) {
|
|
|
3384
3384
|
}
|
|
3385
3385
|
if (typeof d3?.mermaid?.render !== "function" && /\bmermaid\b/i.test(msg)) {
|
|
3386
3386
|
return new Error(
|
|
3387
|
-
"[@bicharts/chart-host] this chart draws its diagram with Mermaid, which it reaches as d3.mermaid.render(...), and the d3 you passed has no mermaid on it \u2014 this host did not load the library. A host supplies it exactly the way the other plugins are supplied:
|
|
3387
|
+
"[@bicharts/chart-host] this chart draws its diagram with Mermaid, which it reaches as d3.mermaid.render(...), and the d3 you passed has no mermaid on it \u2014 this host did not load the library. A host supplies it exactly the way the other plugins are supplied: hand createChartHost ONE d3 that carries it, the SAME d3 every chart gets \u2014 npm install mermaid then import * as d3base from 'd3'; import mermaid from 'mermaid'; import { assembleD3 } from '@bicharts/chart-host'; const d3 = assembleD3(d3base, { mermaid }); (an ES-module d3 namespace is frozen, so assigning onto it throws) Original error: " + msg
|
|
3388
3388
|
);
|
|
3389
3389
|
}
|
|
3390
3390
|
const m = /d3\.(\w+) is not a function|(\w+) is not a function/.exec(msg);
|
|
@@ -3392,7 +3392,7 @@ function explainRenderFailure(err, d3) {
|
|
|
3392
3392
|
const pkg = D3_PLUGIN_PACKAGES[name];
|
|
3393
3393
|
if (pkg) {
|
|
3394
3394
|
return new Error(
|
|
3395
|
-
`[@bicharts/chart-host] this chart calls d3.${name}(), which comes from the separate "${pkg}" package and is not attached to the d3 you passed. Install it and
|
|
3395
|
+
`[@bicharts/chart-host] this chart calls d3.${name}(), which comes from the separate "${pkg}" package and is not attached to the d3 you passed. Install it and hand the host ONE d3 that carries it, the SAME d3 every chart gets: npm install ${pkg} then import * as d3base from "d3"; import { ${name} } from "${pkg}"; import { assembleD3 } from "@bicharts/chart-host"; const d3 = assembleD3(d3base, { ${name} }); (an ES-module d3 namespace is frozen, so assigning onto it throws) Original error: ` + msg
|
|
3396
3396
|
);
|
|
3397
3397
|
}
|
|
3398
3398
|
return err;
|
|
@@ -4108,6 +4108,7 @@ export {
|
|
|
4108
4108
|
sessionViewStateProvider,
|
|
4109
4109
|
noopViewStateProvider,
|
|
4110
4110
|
assembleD3,
|
|
4111
|
+
D3_PLUGIN_PACKAGES,
|
|
4111
4112
|
requiredD3Plugins,
|
|
4112
4113
|
explainRenderFailure,
|
|
4113
4114
|
stripEsmExports,
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
CONTAINER_SLOT_UI_STATE,
|
|
29
29
|
CONTAINER_SLOT_XF_CLEAR,
|
|
30
30
|
CONTROL_CLASS,
|
|
31
|
+
D3_PLUGIN_PACKAGES,
|
|
31
32
|
DARK_TEXT,
|
|
32
33
|
DIM_OPACITY_DEFAULT,
|
|
33
34
|
DIM_OPACITY_VAR,
|
|
@@ -139,7 +140,7 @@ import {
|
|
|
139
140
|
unpinScrolledAxis,
|
|
140
141
|
valuePlacementFlag,
|
|
141
142
|
withoutViewOnlyKeys
|
|
142
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-5IE7AWZY.mjs";
|
|
143
144
|
import "./chunk-A2GMXZP7.mjs";
|
|
144
145
|
import "./chunk-GHODWOAL.mjs";
|
|
145
146
|
|
|
@@ -2445,6 +2446,7 @@ export {
|
|
|
2445
2446
|
CONTAINER_SLOT_UI_STATE,
|
|
2446
2447
|
CONTAINER_SLOT_XF_CLEAR,
|
|
2447
2448
|
CONTROL_CLASS,
|
|
2449
|
+
D3_PLUGIN_PACKAGES,
|
|
2448
2450
|
DARK_TEXT,
|
|
2449
2451
|
DIM_OPACITY_DEFAULT,
|
|
2450
2452
|
DIM_OPACITY_VAR,
|
package/dist/react.mjs
CHANGED
package/dist/types/host.d.ts
CHANGED
|
@@ -245,6 +245,7 @@ export interface ChartHost {
|
|
|
245
245
|
* `requiredD3Plugins(code)` names the plugin packages a given chart needs.
|
|
246
246
|
*/
|
|
247
247
|
export declare function assembleD3(base: object, ...plugins: object[]): Record<string, any>;
|
|
248
|
+
export declare const D3_PLUGIN_PACKAGES: Readonly<Record<string, string>>;
|
|
248
249
|
export declare function requiredD3Plugins(code: string): string[];
|
|
249
250
|
export declare function explainRenderFailure(err: unknown, d3: any): unknown;
|
|
250
251
|
export declare function stripEsmExports(code: string): string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { loadGeo, geoFromCache, registerGeo, registerGeoAsset, geoAssetFor, clea
|
|
|
6
6
|
export declare function registerCityTable(packed: string): void;
|
|
7
7
|
export { buildRenderPayload, type RenderPayload, type GeoPointBinding } from "./payload";
|
|
8
8
|
export { codeReadsDatesInLocalTime, vegaSpecReadsDatesInLocalTime } from "./dateCells";
|
|
9
|
-
export { createChartHost, compileRenderFn, stripEsmExports, requiredD3Plugins, explainRenderFailure, sessionViewStateProvider, noopViewStateProvider, assembleD3, type ChartHost, type ChartHostConfig, type RenderFn } from "./host";
|
|
9
|
+
export { createChartHost, compileRenderFn, stripEsmExports, requiredD3Plugins, explainRenderFailure, sessionViewStateProvider, noopViewStateProvider, assembleD3, D3_PLUGIN_PACKAGES, type ChartHost, type ChartHostConfig, type RenderFn } from "./host";
|
|
10
10
|
export { createChartGroup, toSourceRows, syncMemberSelection, type ChartGroup, type ChartGroupMember, type ChartGroupSelection, type ChartGroupChange, type ChartGroupMemberOptions, type ChartGroupSourceOptions, type ChartGroupPayload } from "./group";
|
|
11
11
|
export { createMarkResolver, isInsideControl, type MarkResolver, type MarkResolverEnv } from "./selection";
|
|
12
12
|
export { planTrivialChart, compileTrivialSource, type TrivialPlan, type TrivialShapeKind } from "./trivial";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
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",
|