@bicharts/chart-host 0.6.8 → 0.6.9

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.
@@ -3936,17 +3936,23 @@ function createChartGroup(columns, rows, opts = {}) {
3936
3936
  attach(id, host, o = {}) {
3937
3937
  const highlight = o.respondsWith === "highlight";
3938
3938
  let rowMap = memberPayload(id, o).rowMap;
3939
+ const filterKey = (incoming) => highlight || !incoming ? "*" : incoming.join(",");
3940
+ let drawnUnder = filterKey(incomingFor(id, o.filteredBy));
3939
3941
  const offHost = host.selection.onChange((payloadIdxs, source) => {
3940
3942
  if (source === "host") return;
3941
3943
  const sourceIdxs = toSourceRows(rowMap, payloadIdxs);
3942
3944
  if (id) group.publish(id, sourceIdxs);
3943
3945
  o.onSelect?.(sourceIdxs);
3944
3946
  });
3945
- const offGroup = group.onChange((sel) => {
3947
+ const offGroup = group.onChange((sel, change) => {
3946
3948
  const incoming = incomingFor(id, o.filteredBy);
3947
- const next = payloadFor(highlight ? null : incoming);
3948
- rowMap = next.rowMap;
3949
- host.setData(next.payload);
3949
+ const key = filterKey(incoming);
3950
+ if (change === "source" || key !== drawnUnder) {
3951
+ const next = payloadFor(highlight ? null : incoming);
3952
+ rowMap = next.rowMap;
3953
+ drawnUnder = key;
3954
+ host.setData(next.payload);
3955
+ }
3950
3956
  syncMemberSelection(host, sel, id, highlight, incoming, rowMap);
3951
3957
  });
3952
3958
  const member = {
package/dist/index.mjs CHANGED
@@ -139,7 +139,7 @@ import {
139
139
  unpinScrolledAxis,
140
140
  valuePlacementFlag,
141
141
  withoutViewOnlyKeys
142
- } from "./chunk-EPEVGRL6.mjs";
142
+ } from "./chunk-GJF6V6BZ.mjs";
143
143
  import "./chunk-A2GMXZP7.mjs";
144
144
  import "./chunk-GHODWOAL.mjs";
145
145
 
package/dist/react.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  loadGeo,
8
8
  syncMemberSelection,
9
9
  toSourceRows
10
- } from "./chunk-EPEVGRL6.mjs";
10
+ } from "./chunk-GJF6V6BZ.mjs";
11
11
  import "./chunk-A2GMXZP7.mjs";
12
12
  import "./chunk-GHODWOAL.mjs";
13
13
 
@@ -35,11 +35,7 @@ function BicChartGroup({ rows, columns, geo, point, children }) {
35
35
  useEffect(() => group.onChange((s, change) => {
36
36
  if (change !== "source") setSel(s);
37
37
  }), [group]);
38
- const value = useMemo(
39
- () => ({ group, selection: sel }),
40
- // eslint-disable-next-line react-hooks/exhaustive-deps
41
- [group, sel, source]
42
- );
38
+ const value = useMemo(() => ({ group, selection: sel, source }), [group, sel, source]);
43
39
  return /* @__PURE__ */ jsx(Ctx.Provider, { value, children });
44
40
  }
45
41
  function BicChart(props) {
@@ -71,9 +67,11 @@ function BicChart(props) {
71
67
  const built = useMemo(() => {
72
68
  if (!group) return null;
73
69
  return group.payloadFor(filterSel);
74
- }, [ctx, filterSel && filterSel.join(",")]);
70
+ }, [group, ctx?.source, filterSel && filterSel.join(",")]);
75
71
  const data = built ? built.payload : props.data;
76
72
  rowMapRef.current = built ? built.rowMap : null;
73
+ const optKey = useMemo(() => JSON.stringify(options ?? {}), [options]);
74
+ const builtWithRef = useRef(null);
77
75
  const onSelectRef = useRef(onSelect);
78
76
  onSelectRef.current = onSelect;
79
77
  const onLabelContrastRef = useRef(onLabelContrast);
@@ -124,18 +122,24 @@ function BicChart(props) {
124
122
  onSelectRef.current?.(sourceIdxs);
125
123
  });
126
124
  host.render();
125
+ builtWithRef.current = { data, optKey };
127
126
  return () => {
128
127
  off();
129
128
  host.destroy();
130
129
  hostRef.current = null;
131
130
  };
132
131
  }, [code, renderFn, d3, geoKind, labelContrast]);
133
- const optKey = useMemo(() => JSON.stringify(options ?? {}), [options]);
134
132
  useEffect(() => {
135
- if (hostRef.current && options) hostRef.current.setOptions(options);
133
+ if (!hostRef.current || !options) return;
134
+ if (builtWithRef.current?.optKey === optKey) return;
135
+ builtWithRef.current = { ...builtWithRef.current, optKey };
136
+ hostRef.current.setOptions(options);
136
137
  }, [optKey]);
137
138
  useEffect(() => {
138
- if (hostRef.current && data) hostRef.current.setData(data);
139
+ if (!hostRef.current || !data) return;
140
+ if (builtWithRef.current?.data === data) return;
141
+ builtWithRef.current = { ...builtWithRef.current, data };
142
+ hostRef.current.setData(data);
139
143
  }, [data]);
140
144
  useEffect(() => {
141
145
  const host = hostRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
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",