@bicharts/chart-host 0.5.75 → 0.5.76

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/dist/react.mjs CHANGED
@@ -51,6 +51,8 @@ function BicChart(props) {
51
51
  d3,
52
52
  geoKind,
53
53
  viewState,
54
+ labelContrast,
55
+ onLabelContrast,
54
56
  id,
55
57
  filteredBy,
56
58
  respondsWith,
@@ -74,6 +76,8 @@ function BicChart(props) {
74
76
  rowMapRef.current = built ? built.rowMap : null;
75
77
  const onSelectRef = useRef(onSelect);
76
78
  onSelectRef.current = onSelect;
79
+ const onLabelContrastRef = useRef(onLabelContrast);
80
+ onLabelContrastRef.current = onLabelContrast;
77
81
  const [geoTick, setGeoTick] = useState(0);
78
82
  useEffect(() => {
79
83
  if (!geoKind || geoFromCache(geoKind)) return;
@@ -91,7 +95,17 @@ function BicChart(props) {
91
95
  useLayoutEffect(() => {
92
96
  const el = ref.current;
93
97
  if (!el || !code && !renderFn || !data) return;
94
- const host = createChartHost(el, { code, renderFn, data, options, d3, geoKind, viewState });
98
+ const host = createChartHost(el, {
99
+ code,
100
+ renderFn,
101
+ data,
102
+ options,
103
+ d3,
104
+ geoKind,
105
+ viewState,
106
+ labelContrast,
107
+ onLabelContrast: (r) => onLabelContrastRef.current?.(r)
108
+ });
95
109
  hostRef.current = host;
96
110
  const off = host.selection.onChange((payloadIdxs, source) => {
97
111
  if (source === "host") return;
@@ -106,7 +120,7 @@ function BicChart(props) {
106
120
  host.destroy();
107
121
  hostRef.current = null;
108
122
  };
109
- }, [code, renderFn, d3, geoKind]);
123
+ }, [code, renderFn, d3, geoKind, labelContrast]);
110
124
  const optKey = useMemo(() => JSON.stringify(options ?? {}), [options]);
111
125
  useEffect(() => {
112
126
  if (hostRef.current && options) hostRef.current.setOptions(options);
@@ -25,6 +25,15 @@ export interface BicChartProps {
25
25
  * default could pick between them, which is why this is a prop rather than a flag.
26
26
  */
27
27
  viewState?: ChartHostConfig["viewState"];
28
+ /**
29
+ * CAN THE LABELS ON THE MARKS BE READ? Default on: after every render a label sitting on a
30
+ * mark it cannot be read against is recoloured black or white. Pass `false` for a page that
31
+ * owns its label colours, or `{ pageBg }` to name the canvas the chart sits on - a dark or
32
+ * themed page is not white, and readability is measured against it. See createChartHost.
33
+ */
34
+ labelContrast?: ChartHostConfig["labelContrast"];
35
+ /** What the label-contrast pass did after each render - counts, for a page that logs. */
36
+ onLabelContrast?: ChartHostConfig["onLabelContrast"];
28
37
  /** Identity within a <BicChartGroup> — the key other charts filter by. */
29
38
  id?: string;
30
39
  /** Take this group member's selection as a filter on THIS chart's rows. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.5.75",
3
+ "version": "0.5.76",
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",