@bicharts/chart-host 0.6.95 → 0.6.97
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 +9 -1
- package/dist/adapters.mjs +3 -3
- package/dist/card.mjs +2 -2
- package/dist/{chunk-NNLBFIWU.mjs → chunk-3JBJ2SIF.mjs} +1 -1
- package/dist/{chunk-VEVBXK44.mjs → chunk-5OCL4EFM.mjs} +1 -1
- package/dist/{chunk-PDVEIW42.mjs → chunk-ASLRGGLV.mjs} +1 -1
- package/dist/{chunk-QHMLMF4L.mjs → chunk-B6BLSIID.mjs} +34 -2
- package/dist/{chunk-NQFJHNMC.mjs → chunk-KFU44UEN.mjs} +346 -316
- package/dist/{chunk-45VILLJT.mjs → chunk-M7MBTLDP.mjs} +1 -1
- package/dist/{chunk-CJ4IG6G5.mjs → chunk-P6VCB6SF.mjs} +19 -19
- package/dist/{chunk-VC3Z5CH7.mjs → chunk-PMA56BKD.mjs} +1 -1
- package/dist/{chunk-4ICQEVZX.mjs → chunk-SFDKACWG.mjs} +86 -30
- package/dist/{chunk-CR7DSJVG.mjs → chunk-WSNDXS3Z.mjs} +1 -1
- package/dist/index.mjs +13 -9
- package/dist/legend-fit.mjs +3 -3
- package/dist/page.mjs +4 -4
- package/dist/react.mjs +25 -14
- package/dist/testing.mjs +1 -1
- package/dist/types/contract.d.ts +6 -1
- package/dist/types/host.d.ts +9 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lasso.d.ts +18 -1
- package/dist/types/payload.d.ts +5 -0
- package/dist/zoom-memory.mjs +3 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
|
3
3
|
// src/contract.ts
|
|
4
|
-
var HOST_CONTRACT_VERSION = "1.
|
|
4
|
+
var HOST_CONTRACT_VERSION = "1.17.0";
|
|
5
5
|
var GEO_POINT_PRECISIONS = ["latlon", "city", "zip3", "state", "country"];
|
|
6
6
|
var MARK_CLASS = "d3-mark";
|
|
7
7
|
var LEGEND_MARK_CLASS = "d3-legend-mark";
|
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
3
|
+
It,
|
|
4
|
+
Nt,
|
|
5
|
+
j,
|
|
6
|
+
mi,
|
|
7
|
+
u,
|
|
8
|
+
ui
|
|
9
|
+
} from "./chunk-KFU44UEN.mjs";
|
|
10
10
|
|
|
11
11
|
// src/sourceDateFormat.ts
|
|
12
12
|
function formatSourceDate(raw, opts = {}) {
|
|
13
13
|
const d = toDate(raw);
|
|
14
14
|
if (!d) return null;
|
|
15
|
-
const dayFrame =
|
|
15
|
+
const dayFrame = u(d);
|
|
16
16
|
const frame = dayFrame ?? (opts.dialect === "dotnet" ? "local" : "utc");
|
|
17
17
|
const p = partsIn(d, frame);
|
|
18
18
|
const format = cleanFormat(opts.format, opts.dialect);
|
|
@@ -33,7 +33,7 @@ var ISO_LIKE_RE = /^\s*\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(
|
|
|
33
33
|
function toDate(raw) {
|
|
34
34
|
if (raw instanceof Date) return isNaN(raw.getTime()) ? null : raw;
|
|
35
35
|
if (typeof raw !== "string" || !ISO_LIKE_RE.test(raw)) return null;
|
|
36
|
-
const d =
|
|
36
|
+
const d = j(raw.trim());
|
|
37
37
|
return d && !isNaN(d.getTime()) ? d : null;
|
|
38
38
|
}
|
|
39
39
|
function partsIn(d, frame) {
|
|
@@ -225,15 +225,15 @@ function resolveAmbiguousM(tokens) {
|
|
|
225
225
|
if (t.kind !== "mAmbiguous1" && t.kind !== "mAmbiguous2") continue;
|
|
226
226
|
const two = t.kind === "mAmbiguous2";
|
|
227
227
|
let minute = false;
|
|
228
|
-
for (let
|
|
229
|
-
if (tokens[
|
|
230
|
-
minute = isHour(tokens[
|
|
228
|
+
for (let j2 = i - 1; j2 >= 0; j2--) {
|
|
229
|
+
if (tokens[j2].kind === "literal") continue;
|
|
230
|
+
minute = isHour(tokens[j2]);
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
233
|
if (!minute) {
|
|
234
|
-
for (let
|
|
235
|
-
if (tokens[
|
|
236
|
-
minute = isSecond(tokens[
|
|
234
|
+
for (let j2 = i + 1; j2 < tokens.length; j2++) {
|
|
235
|
+
if (tokens[j2].kind === "literal") continue;
|
|
236
|
+
minute = isSecond(tokens[j2]);
|
|
237
237
|
break;
|
|
238
238
|
}
|
|
239
239
|
}
|
|
@@ -435,15 +435,15 @@ function displayText(col, raw, opts) {
|
|
|
435
435
|
return String(raw);
|
|
436
436
|
}
|
|
437
437
|
function isSuppressed(col) {
|
|
438
|
-
return
|
|
438
|
+
return It(col).suppressed;
|
|
439
439
|
}
|
|
440
440
|
function resolveAgg(col, requested, auto) {
|
|
441
441
|
const fallback = () => {
|
|
442
|
-
const d =
|
|
442
|
+
const d = ui(col);
|
|
443
443
|
return d === "first" ? "count" : d;
|
|
444
444
|
};
|
|
445
445
|
if (auto) return fallback();
|
|
446
|
-
return
|
|
446
|
+
return Nt(col).indexOf(requested) >= 0 ? requested : fallback();
|
|
447
447
|
}
|
|
448
448
|
function toNumber(v) {
|
|
449
449
|
if (v == null || v === "") return null;
|
|
@@ -546,7 +546,7 @@ function computeSelectionCard(payload, selectedRowIdxs, opts = {}) {
|
|
|
546
546
|
}
|
|
547
547
|
const value = reduce(selVals, colAgg, selRaw);
|
|
548
548
|
let sharePct = null;
|
|
549
|
-
if (
|
|
549
|
+
if (mi(col, colAgg) && value != null) {
|
|
550
550
|
const allVals = [];
|
|
551
551
|
const allRaw = [];
|
|
552
552
|
for (let r = 0; r < rows.length; r++) {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
SNAPSHOT_SVG_ATTR
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M7MBTLDP.mjs";
|
|
5
5
|
|
|
6
6
|
// src/snapshot.ts
|
|
7
7
|
var DEFAULT_TIMEOUT_MS = 2e3;
|
|
@@ -1,12 +1,14 @@
|
|
|
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
|
LASSO_OUTLINE_CLASS,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
claimParkedLasso,
|
|
5
|
+
installLasso,
|
|
6
|
+
lassoEffect
|
|
7
|
+
} from "./chunk-B6BLSIID.mjs";
|
|
6
8
|
import {
|
|
7
9
|
censusHitBands,
|
|
8
10
|
ensureCrossfilterHitTargets
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ASLRGGLV.mjs";
|
|
10
12
|
import {
|
|
11
13
|
clearPress,
|
|
12
14
|
clearSelectionGlyphs,
|
|
@@ -23,21 +25,22 @@ import {
|
|
|
23
25
|
selectionRuleOf,
|
|
24
26
|
trackPress,
|
|
25
27
|
validRowSet
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-5OCL4EFM.mjs";
|
|
27
29
|
import {
|
|
28
30
|
clipWindowOf,
|
|
29
31
|
fitRenderedChart,
|
|
30
32
|
rememberScroll,
|
|
31
33
|
takeScroll,
|
|
32
34
|
unpinScrolledAxis
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-3JBJ2SIF.mjs";
|
|
34
36
|
import {
|
|
35
37
|
Fn,
|
|
36
38
|
J3,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
Q,
|
|
40
|
+
Yn,
|
|
41
|
+
or,
|
|
42
|
+
tt
|
|
43
|
+
} from "./chunk-KFU44UEN.mjs";
|
|
41
44
|
import {
|
|
42
45
|
NA_ISO3,
|
|
43
46
|
NA_LAT_MAX,
|
|
@@ -84,7 +87,7 @@ import {
|
|
|
84
87
|
XFILTER_REFRESH_EVENT,
|
|
85
88
|
chartOwnsTimeline,
|
|
86
89
|
periodTickSuppressesFeedback
|
|
87
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-M7MBTLDP.mjs";
|
|
88
91
|
|
|
89
92
|
// src/labelContrast.ts
|
|
90
93
|
function parseRGBA(c) {
|
|
@@ -265,10 +268,10 @@ function f(t) {
|
|
|
265
268
|
}
|
|
266
269
|
function rgbToLab(r, g, b) {
|
|
267
270
|
const R = linearise(r), G = linearise(g), B = linearise(b);
|
|
268
|
-
const
|
|
271
|
+
const X = 0.4124564 * R + 0.3575761 * G + 0.1804375 * B;
|
|
269
272
|
const Y = 0.2126729 * R + 0.7151522 * G + 0.072175 * B;
|
|
270
273
|
const Z = 0.0193339 * R + 0.119192 * G + 0.9503041 * B;
|
|
271
|
-
const fx = f(
|
|
274
|
+
const fx = f(X / Xn), fy = f(Y / Yn2), fz = f(Z / Zn);
|
|
272
275
|
return { L: 116 * fy - 16, a: 500 * (fx - fy), b: 200 * (fy - fz) };
|
|
273
276
|
}
|
|
274
277
|
function hexToLab(hex2) {
|
|
@@ -323,13 +326,13 @@ function labToHex(lab) {
|
|
|
323
326
|
return t3 > EPS ? t3 : (116 * t - 16) / KAPPA;
|
|
324
327
|
};
|
|
325
328
|
const fy = (lab.L + 16) / 116, fx = fy + lab.a / 500, fz = fy - lab.b / 200;
|
|
326
|
-
const
|
|
329
|
+
const X = Xn * finv(fx);
|
|
327
330
|
const Y = Yn2 * (lab.L > KAPPA * EPS ? fy * fy * fy : lab.L / KAPPA);
|
|
328
331
|
const Z = Zn * finv(fz);
|
|
329
332
|
const lin = [
|
|
330
|
-
3.2404542 *
|
|
331
|
-
-0.969266 *
|
|
332
|
-
0.0556434 *
|
|
333
|
+
3.2404542 * X - 1.5371385 * Y - 0.4985314 * Z,
|
|
334
|
+
-0.969266 * X + 1.8760108 * Y + 0.041556 * Z,
|
|
335
|
+
0.0556434 * X - 0.2040259 * Y + 1.0572252 * Z
|
|
333
336
|
];
|
|
334
337
|
return "#" + lin.map((v) => {
|
|
335
338
|
const c = Math.max(0, Math.min(1, v));
|
|
@@ -851,7 +854,7 @@ function resolvePointChannel(cols, rowObjs, point) {
|
|
|
851
854
|
let labelCol;
|
|
852
855
|
if (bind) {
|
|
853
856
|
const dims = cols.filter((c) => !c.isMeasure).map((c) => c.name);
|
|
854
|
-
const res =
|
|
857
|
+
const res = or(dims, rowObjs, bind, point?.mapKind, cols.map((c) => c.name));
|
|
855
858
|
bind = res.bind;
|
|
856
859
|
rolesBackfilled = res.backfilled;
|
|
857
860
|
rolesRefused = res.refused;
|
|
@@ -899,10 +902,16 @@ function buildRenderPayload(cols, rowObjs, geo, point, destination, opts) {
|
|
|
899
902
|
cols = cols.filter((c) => c.name !== ROW_IDX_COLUMN);
|
|
900
903
|
let utcDayColumns = null;
|
|
901
904
|
if (opts?.utcDays) {
|
|
902
|
-
const norm =
|
|
905
|
+
const norm = Q(cols, rowObjs);
|
|
903
906
|
rowObjs = norm.rows;
|
|
904
907
|
utcDayColumns = norm.columns;
|
|
905
908
|
}
|
|
909
|
+
let utcWallClockColumns = null;
|
|
910
|
+
if (opts?.localWallClock) {
|
|
911
|
+
const wall = tt(cols, rowObjs);
|
|
912
|
+
rowObjs = wall.rows;
|
|
913
|
+
utcWallClockColumns = wall.columns;
|
|
914
|
+
}
|
|
906
915
|
const o = resolvePointChannel(cols, rowObjs, point);
|
|
907
916
|
const d = resolvePointChannel(cols, rowObjs, destination);
|
|
908
917
|
const pLat = o.lat, pLon = o.lon, pPrec = o.prec;
|
|
@@ -993,7 +1002,8 @@ function buildRenderPayload(cols, rowObjs, geo, point, destination, opts) {
|
|
|
993
1002
|
// Survives a refusal that placed nothing — see geoPointRefused. Omitted when empty so
|
|
994
1003
|
// the ordinary case adds no bytes.
|
|
995
1004
|
...rolesRefused.length ? { geoPointRefused: rolesRefused } : {},
|
|
996
|
-
...utcDayColumns ? { dateCellsAreUtcDays: true, utcDayColumns } : {}
|
|
1005
|
+
...utcDayColumns ? { dateCellsAreUtcDays: true, utcDayColumns } : {},
|
|
1006
|
+
...utcWallClockColumns ? { dateCellsAreUtcWallClock: true, utcWallClockColumns } : {}
|
|
997
1007
|
};
|
|
998
1008
|
}
|
|
999
1009
|
|
|
@@ -2036,6 +2046,12 @@ function compileRenderFn(code, win, doc, d3) {
|
|
|
2036
2046
|
var ASYNC_RENDER_TIMEOUT_MS = 15e3;
|
|
2037
2047
|
var isThenable = (v) => !!v && (typeof v === "object" || typeof v === "function") && typeof v.then === "function";
|
|
2038
2048
|
var dimVarPage = /* @__PURE__ */ new WeakMap();
|
|
2049
|
+
var readDimVar = (el) => {
|
|
2050
|
+
const s = el.style;
|
|
2051
|
+
if (!s || typeof s.getPropertyValue !== "function") return null;
|
|
2052
|
+
return { value: s.getPropertyValue(DIM_OPACITY_VAR) ?? "", priority: typeof s.getPropertyPriority === "function" ? s.getPropertyPriority(DIM_OPACITY_VAR) ?? "" : "" };
|
|
2053
|
+
};
|
|
2054
|
+
var sameDimVar = (a, b) => !!b && a.value === b.value && a.priority === b.priority;
|
|
2039
2055
|
function createChartHost(container, config) {
|
|
2040
2056
|
const doc = container.ownerDocument;
|
|
2041
2057
|
const win = doc?.defaultView ?? globalThis;
|
|
@@ -2055,6 +2071,15 @@ function createChartHost(container, config) {
|
|
|
2055
2071
|
}
|
|
2056
2072
|
}
|
|
2057
2073
|
let raw = { ...config.options ?? {} };
|
|
2074
|
+
let lassoKey = config.code;
|
|
2075
|
+
if (!lassoKey && typeof config.renderFn === "function") {
|
|
2076
|
+
try {
|
|
2077
|
+
lassoKey = Function.prototype.toString.call(config.renderFn);
|
|
2078
|
+
} catch {
|
|
2079
|
+
lassoKey = config.renderFn;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
let lassoClaimed = false;
|
|
2058
2083
|
if (typeof raw.setUiState !== "function") {
|
|
2059
2084
|
const provider = config.viewState ?? sessionViewStateProvider(container);
|
|
2060
2085
|
let bag;
|
|
@@ -2063,6 +2088,8 @@ function createChartHost(container, config) {
|
|
|
2063
2088
|
} catch {
|
|
2064
2089
|
bag = {};
|
|
2065
2090
|
}
|
|
2091
|
+
claimParkedLasso(container, lassoKey, config.viewState ? null : bag);
|
|
2092
|
+
lassoClaimed = true;
|
|
2066
2093
|
if (raw.uiState && typeof raw.uiState === "object" && Object.keys(bag).length === 0)
|
|
2067
2094
|
Object.assign(bag, raw.uiState);
|
|
2068
2095
|
raw.uiState = bag;
|
|
@@ -2078,12 +2105,14 @@ function createChartHost(container, config) {
|
|
|
2078
2105
|
const out = resolveOptions(input);
|
|
2079
2106
|
return out.allowTooltips == null ? { ...out, allowTooltips: true } : out;
|
|
2080
2107
|
};
|
|
2108
|
+
if (!lassoClaimed) claimParkedLasso(container, lassoKey);
|
|
2081
2109
|
let resolved = resolveForHost(raw);
|
|
2082
2110
|
let renderFn = config.renderFn ?? null;
|
|
2083
2111
|
let destroyed = false;
|
|
2084
2112
|
let warnedGeo = false;
|
|
2085
2113
|
let warnedBlank = false;
|
|
2086
2114
|
let warnedIds = false;
|
|
2115
|
+
let warnedLassoNoFilter = false;
|
|
2087
2116
|
const idScope = newIdScope();
|
|
2088
2117
|
let renderSeq = 0;
|
|
2089
2118
|
const annotationLayer = createAnnotationLayer(container, (a) => config.onAnnotationClick?.(a));
|
|
@@ -2110,7 +2139,8 @@ function createChartHost(container, config) {
|
|
|
2110
2139
|
if (!page || --page.holders > 0) return;
|
|
2111
2140
|
dimVarPage.delete(container);
|
|
2112
2141
|
try {
|
|
2113
|
-
|
|
2142
|
+
const now = readDimVar(container);
|
|
2143
|
+
if (now && !sameDimVar(now, page.wrote)) return;
|
|
2114
2144
|
if (page.was) container.style?.setProperty(DIM_OPACITY_VAR, page.was.value, page.was.priority);
|
|
2115
2145
|
else container.style?.removeProperty(DIM_OPACITY_VAR);
|
|
2116
2146
|
} catch {
|
|
@@ -2120,6 +2150,7 @@ function createChartHost(container, config) {
|
|
|
2120
2150
|
let activeTickEl = null;
|
|
2121
2151
|
let selectionIsPeriod = false;
|
|
2122
2152
|
let selectionFromChart = false;
|
|
2153
|
+
let selectionPublished = true;
|
|
2123
2154
|
const clickedMarks = () => container[CONTAINER_SLOT_CLICKED_MARKS] ?? null;
|
|
2124
2155
|
const setClickedMarks = (c) => {
|
|
2125
2156
|
try {
|
|
@@ -2197,16 +2228,18 @@ function createChartHost(container, config) {
|
|
|
2197
2228
|
if (typeof want === "number") {
|
|
2198
2229
|
const level = String(want);
|
|
2199
2230
|
let page = dimVarPage.get(container);
|
|
2231
|
+
const now = readDimVar(container);
|
|
2232
|
+
if (!page) {
|
|
2233
|
+
page = { was: now?.value ? now : null, holders: 0, wrote: null };
|
|
2234
|
+
dimVarPage.set(container, page);
|
|
2235
|
+
} else if (now && page.wrote && !sameDimVar(now, page.wrote)) {
|
|
2236
|
+
page.was = now.value ? now : null;
|
|
2237
|
+
}
|
|
2200
2238
|
if (!dimVarSet) {
|
|
2201
|
-
if (!page) {
|
|
2202
|
-
const value = container.style?.getPropertyValue?.(DIM_OPACITY_VAR) ?? "";
|
|
2203
|
-
page = { was: value ? { value, priority: container.style?.getPropertyPriority?.(DIM_OPACITY_VAR) ?? "" } : null, holders: 0, wrote: level };
|
|
2204
|
-
dimVarPage.set(container, page);
|
|
2205
|
-
}
|
|
2206
2239
|
page.holders++;
|
|
2207
2240
|
dimVarSet = true;
|
|
2208
2241
|
}
|
|
2209
|
-
|
|
2242
|
+
page.wrote = { value: level, priority: "" };
|
|
2210
2243
|
container.style?.setProperty(DIM_OPACITY_VAR, level);
|
|
2211
2244
|
} else releaseDimVar();
|
|
2212
2245
|
const lit = container.querySelectorAll(`.${ACTIVE_TICK_CLASS}`);
|
|
@@ -2444,14 +2477,16 @@ function createChartHost(container, config) {
|
|
|
2444
2477
|
}
|
|
2445
2478
|
}
|
|
2446
2479
|
};
|
|
2447
|
-
const notify = (rowIdxs, source, tick, fromChart = false) => {
|
|
2480
|
+
const notify = (rowIdxs, source, tick, fromChart = false, publish = true) => {
|
|
2448
2481
|
if (destroyed) return;
|
|
2449
2482
|
current = rowIdxs;
|
|
2450
2483
|
selectionFromChart = rowIdxs.length > 0 && fromChart;
|
|
2484
|
+
selectionPublished = publish;
|
|
2451
2485
|
activeTickEl = rowIdxs.length ? tick ?? null : null;
|
|
2452
2486
|
selectionIsPeriod = rowIdxs.length > 0 && periodTickSuppressesFeedback(!!tick, chartOwnsTimeline(container));
|
|
2453
2487
|
paintSelection();
|
|
2454
2488
|
paintGlyphLayer();
|
|
2489
|
+
if (!publish) return;
|
|
2455
2490
|
for (const cb of subs) {
|
|
2456
2491
|
try {
|
|
2457
2492
|
cb(rowIdxs, source);
|
|
@@ -2459,12 +2494,33 @@ function createChartHost(container, config) {
|
|
|
2459
2494
|
}
|
|
2460
2495
|
}
|
|
2461
2496
|
};
|
|
2497
|
+
const selectFromLasso = (rows) => {
|
|
2498
|
+
if (lassoEffect(resolved.lasso) === "highlight") {
|
|
2499
|
+
notify(rows, "user", null, true, false);
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
notify(rows, "user", null, true);
|
|
2503
|
+
if (warnedLassoNoFilter || !rows.length) return;
|
|
2504
|
+
let reaches = true;
|
|
2505
|
+
try {
|
|
2506
|
+
reaches = config.selectionReachesPage ? config.selectionReachesPage() !== false : subs.size > 0;
|
|
2507
|
+
} catch {
|
|
2508
|
+
}
|
|
2509
|
+
if (reaches) return;
|
|
2510
|
+
warnedLassoNoFilter = true;
|
|
2511
|
+
try {
|
|
2512
|
+
(win?.console ?? console)?.warn(
|
|
2513
|
+
`[@bicharts/chart-host] a lasso circled ${rows.length} ${rows.length === 1 ? "row" : "rows"}, but the page gave this chart no filter to set (no \`selects\` or bindFilter, no chart group), so the lasso only highlights inside the chart and the rest of the page does not follow. To filter the page, pass selects={useBicFilter("<key column>")} to this chart and filter the other charts by that filter; for a highlight on purpose, set lasso.effect to "highlight".`
|
|
2514
|
+
);
|
|
2515
|
+
} catch {
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2462
2518
|
let xfAt = 0;
|
|
2463
2519
|
const XF_ECHO_MS = 150;
|
|
2464
2520
|
const onXf = (e) => {
|
|
2465
2521
|
const d = e?.detail || {};
|
|
2466
2522
|
xfAt = Date.now();
|
|
2467
|
-
if (d.clear) notify([], d.source || "chart");
|
|
2523
|
+
if (d.clear) notify([], d.source || "chart", void 0, false, selectionPublished || !(current && current.length));
|
|
2468
2524
|
else if (d.mark) notify(parseRowIdxs(d.mark.getAttribute?.(ROW_IDX_ATTR)), d.source || "chart", d.mark, true);
|
|
2469
2525
|
else if (Array.isArray(d.rows)) notify(validRowSet(d.rows), d.source || "chart", null, true);
|
|
2470
2526
|
};
|
|
@@ -2483,7 +2539,7 @@ function createChartHost(container, config) {
|
|
|
2483
2539
|
} catch {
|
|
2484
2540
|
}
|
|
2485
2541
|
}
|
|
2486
|
-
if (current && current.length) notify([], "user");
|
|
2542
|
+
if (current && current.length) notify([], "user", void 0, false, selectionPublished);
|
|
2487
2543
|
}
|
|
2488
2544
|
};
|
|
2489
2545
|
let lasso = null;
|
|
@@ -2679,7 +2735,7 @@ function createChartHost(container, config) {
|
|
|
2679
2735
|
container,
|
|
2680
2736
|
options: () => resolved,
|
|
2681
2737
|
rows: data.rows ? data.rows.length : 0,
|
|
2682
|
-
select:
|
|
2738
|
+
select: selectFromLasso,
|
|
2683
2739
|
clearSelection: clearFromGesture
|
|
2684
2740
|
});
|
|
2685
2741
|
} catch {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
LASSO_KNOB_KEY
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-B6BLSIID.mjs";
|
|
5
5
|
|
|
6
6
|
// src/filterScope.ts
|
|
7
7
|
function viewToken(view) {
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
formatSourceDateFor,
|
|
6
6
|
isExcelDateFormat,
|
|
7
7
|
normaliseAggregation
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-P6VCB6SF.mjs";
|
|
9
9
|
import {
|
|
10
10
|
captureSvgSnapshot,
|
|
11
11
|
chartSvgOf,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
svgNaturalSize,
|
|
16
16
|
svgToDataUrl,
|
|
17
17
|
tableHostOf
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-PMA56BKD.mjs";
|
|
19
19
|
import {
|
|
20
20
|
ANNOTATION_CLASS,
|
|
21
21
|
ANNOTATION_LAYER_CLASS,
|
|
@@ -97,11 +97,12 @@ import {
|
|
|
97
97
|
toRGBA,
|
|
98
98
|
toSourceRows,
|
|
99
99
|
valuePlacementFlag
|
|
100
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-SFDKACWG.mjs";
|
|
101
101
|
import {
|
|
102
102
|
LASSO_AXES_SLOT,
|
|
103
103
|
LASSO_COUNT_CLASS,
|
|
104
104
|
LASSO_DEFAULT_ACTIONS,
|
|
105
|
+
LASSO_DEFAULT_EFFECT,
|
|
105
106
|
LASSO_DRAG_PX,
|
|
106
107
|
LASSO_EVENT,
|
|
107
108
|
LASSO_KNOB_KEY,
|
|
@@ -118,17 +119,18 @@ import {
|
|
|
118
119
|
clearLasso,
|
|
119
120
|
installLasso,
|
|
120
121
|
lassoActions,
|
|
122
|
+
lassoEffect,
|
|
121
123
|
lassoRowCap,
|
|
122
124
|
lassoVerdict,
|
|
123
125
|
pointInShape,
|
|
124
126
|
registerLassoAction
|
|
125
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-B6BLSIID.mjs";
|
|
126
128
|
import {
|
|
127
129
|
MIN_HIT_BAND_PX,
|
|
128
130
|
censusHitBands,
|
|
129
131
|
ensureCrossfilterHitTargets,
|
|
130
132
|
hitBandFlag
|
|
131
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-ASLRGGLV.mjs";
|
|
132
134
|
import {
|
|
133
135
|
CONTAINER_SLOT_PRESS_AT,
|
|
134
136
|
DRAG_NOT_CLICK_PX,
|
|
@@ -153,7 +155,7 @@ import {
|
|
|
153
155
|
selectionRuleOf,
|
|
154
156
|
trackPress,
|
|
155
157
|
validRowSet
|
|
156
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-5OCL4EFM.mjs";
|
|
157
159
|
import {
|
|
158
160
|
AXIS_PIN_BAND_PAD_PX,
|
|
159
161
|
AXIS_PIN_MAX_BAND_FRACTION,
|
|
@@ -182,12 +184,12 @@ import {
|
|
|
182
184
|
svgInkReach,
|
|
183
185
|
takeScroll,
|
|
184
186
|
unpinScrolledAxis
|
|
185
|
-
} from "./chunk-
|
|
187
|
+
} from "./chunk-3JBJ2SIF.mjs";
|
|
186
188
|
import {
|
|
187
189
|
_3,
|
|
188
190
|
l,
|
|
189
191
|
o
|
|
190
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-KFU44UEN.mjs";
|
|
191
193
|
import "./chunk-A2GMXZP7.mjs";
|
|
192
194
|
import {
|
|
193
195
|
ACTIVE_TICK_CLASS,
|
|
@@ -241,7 +243,7 @@ import {
|
|
|
241
243
|
chartOwnsTimeline,
|
|
242
244
|
periodTickSuppressesFeedback,
|
|
243
245
|
withoutViewOnlyKeys
|
|
244
|
-
} from "./chunk-
|
|
246
|
+
} from "./chunk-M7MBTLDP.mjs";
|
|
245
247
|
import "./chunk-GHODWOAL.mjs";
|
|
246
248
|
|
|
247
249
|
// src/optionsVocabulary.ts
|
|
@@ -2195,6 +2197,7 @@ export {
|
|
|
2195
2197
|
LASSO_AXES_SLOT,
|
|
2196
2198
|
LASSO_COUNT_CLASS,
|
|
2197
2199
|
LASSO_DEFAULT_ACTIONS,
|
|
2200
|
+
LASSO_DEFAULT_EFFECT,
|
|
2198
2201
|
LASSO_DRAG_PX,
|
|
2199
2202
|
LASSO_EVENT,
|
|
2200
2203
|
LASSO_KNOB_KEY,
|
|
@@ -2360,6 +2363,7 @@ export {
|
|
|
2360
2363
|
isPillBackdropAlpha,
|
|
2361
2364
|
labelBand,
|
|
2362
2365
|
lassoActions,
|
|
2366
|
+
lassoEffect,
|
|
2363
2367
|
lassoRowCap,
|
|
2364
2368
|
lassoVerdict,
|
|
2365
2369
|
latePickupAction,
|
package/dist/legend-fit.mjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
chartSvgOf,
|
|
4
4
|
tableHostOf
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PMA56BKD.mjs";
|
|
6
6
|
import {
|
|
7
7
|
FIT_CONTENT_SELECTOR,
|
|
8
8
|
ctmScaleOf,
|
|
9
9
|
isPhantomBox
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-3JBJ2SIF.mjs";
|
|
11
|
+
import "./chunk-M7MBTLDP.mjs";
|
|
12
12
|
import "./chunk-GHODWOAL.mjs";
|
|
13
13
|
|
|
14
14
|
// src/legendFit/legendReconcile.ts
|
package/dist/page.mjs
CHANGED
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
readControls,
|
|
15
15
|
viewFromToken,
|
|
16
16
|
viewToken
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-WSNDXS3Z.mjs";
|
|
18
|
+
import "./chunk-B6BLSIID.mjs";
|
|
19
|
+
import "./chunk-5OCL4EFM.mjs";
|
|
20
|
+
import "./chunk-M7MBTLDP.mjs";
|
|
21
21
|
import "./chunk-GHODWOAL.mjs";
|
|
22
22
|
export {
|
|
23
23
|
LINKED_HOVER_CLASS,
|
package/dist/react.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
payloadRowReader,
|
|
14
14
|
viewFromToken,
|
|
15
15
|
viewToken
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WSNDXS3Z.mjs";
|
|
17
17
|
import {
|
|
18
18
|
assembleD3,
|
|
19
19
|
createChartGroup,
|
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
loadGeo,
|
|
23
23
|
syncMemberSelection,
|
|
24
24
|
toSourceRows
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-SFDKACWG.mjs";
|
|
26
|
+
import "./chunk-B6BLSIID.mjs";
|
|
27
|
+
import "./chunk-ASLRGGLV.mjs";
|
|
28
|
+
import "./chunk-5OCL4EFM.mjs";
|
|
29
|
+
import "./chunk-3JBJ2SIF.mjs";
|
|
30
|
+
import "./chunk-KFU44UEN.mjs";
|
|
31
31
|
import "./chunk-A2GMXZP7.mjs";
|
|
32
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-M7MBTLDP.mjs";
|
|
33
33
|
import "./chunk-GHODWOAL.mjs";
|
|
34
34
|
|
|
35
35
|
// src/react.tsx
|
|
@@ -113,12 +113,15 @@ function BicChart(props) {
|
|
|
113
113
|
};
|
|
114
114
|
const userSelectedRef = useRef(false);
|
|
115
115
|
const optKey = useMemo(() => JSON.stringify(options ?? {}), [options]);
|
|
116
|
-
const zoomOn = zoomMemory
|
|
117
|
-
const zoomRef = useRef(zoomMemory
|
|
116
|
+
const zoomOn = !!zoomMemory;
|
|
117
|
+
const zoomRef = useRef(zoomMemory || null);
|
|
118
118
|
useLayoutEffect(() => {
|
|
119
|
-
zoomRef.current = zoomMemory
|
|
119
|
+
zoomRef.current = zoomMemory || null;
|
|
120
120
|
});
|
|
121
|
+
const [lateData, setLateData] = useState(0);
|
|
121
122
|
const builtWithRef = useRef(null);
|
|
123
|
+
const reachRef = useRef({ selects, group, id });
|
|
124
|
+
reachRef.current = { selects, group, id };
|
|
122
125
|
const onSelectRef = useRef(onSelect);
|
|
123
126
|
onSelectRef.current = onSelect;
|
|
124
127
|
const onLabelContrastRef = useRef(onLabelContrast);
|
|
@@ -175,7 +178,12 @@ function BicChart(props) {
|
|
|
175
178
|
return onInvalidSentinelRef.current ? (info) => onInvalidSentinelRef.current?.(info) : void 0;
|
|
176
179
|
},
|
|
177
180
|
annotations: annotationsRef.current ?? [],
|
|
178
|
-
onAnnotationClick: (a) => onAnnotationClickRef.current?.(a)
|
|
181
|
+
onAnnotationClick: (a) => onAnnotationClickRef.current?.(a),
|
|
182
|
+
// What a filtering lasso reaches: the page filter (`selects`), or the
|
|
183
|
+
// siblings of a chart that has an id in a group. This binding always
|
|
184
|
+
// subscribes to the selection (for onSelect), so the host cannot count
|
|
185
|
+
// subscribers here; an onSelect callback alone is not the page's filter.
|
|
186
|
+
selectionReachesPage: () => !!reachRef.current.selects || !!(reachRef.current.group && reachRef.current.id)
|
|
179
187
|
});
|
|
180
188
|
hostRef.current = host;
|
|
181
189
|
builtAnnKeyRef.current = annKey;
|
|
@@ -196,7 +204,10 @@ function BicChart(props) {
|
|
|
196
204
|
host.destroy();
|
|
197
205
|
hostRef.current = null;
|
|
198
206
|
};
|
|
199
|
-
}, [code, renderFn, d3, geoKind, labelContrast, layoutPass, restoreScroll, zoomOn, controls]);
|
|
207
|
+
}, [code, renderFn, d3, geoKind, labelContrast, layoutPass, restoreScroll, zoomOn, controls, lateData]);
|
|
208
|
+
useLayoutEffect(() => {
|
|
209
|
+
if (!hostRef.current && data && ref.current && (code || renderFn)) setLateData((n) => n + 1);
|
|
210
|
+
}, [data]);
|
|
200
211
|
useLayoutEffect(() => {
|
|
201
212
|
const host = hostRef.current;
|
|
202
213
|
if (!host || !selects) return;
|
|
@@ -222,7 +233,7 @@ function BicChart(props) {
|
|
|
222
233
|
b.detach();
|
|
223
234
|
if (bindingRef.current === b) bindingRef.current = null;
|
|
224
235
|
};
|
|
225
|
-
}, [selects, code, renderFn, d3, geoKind, labelContrast, layoutPass, restoreScroll, zoomOn]);
|
|
236
|
+
}, [selects, code, renderFn, d3, geoKind, labelContrast, layoutPass, restoreScroll, zoomOn, controls, lateData]);
|
|
226
237
|
useEffect(() => {
|
|
227
238
|
if (!hostRef.current || !options) return;
|
|
228
239
|
if (builtWithRef.current?.optKey === optKey) return;
|
package/dist/testing.mjs
CHANGED
package/dist/types/contract.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const HOST_CONTRACT_VERSION = "1.
|
|
1
|
+
export declare const HOST_CONTRACT_VERSION = "1.17.0";
|
|
2
2
|
export type GeoPointPrecision = "latlon" | "city" | "zip3" | "state" | "country";
|
|
3
3
|
/** Every valid tier, ordered most precise → coarsest. Runtime form of GeoPointPrecision. */
|
|
4
4
|
export declare const GEO_POINT_PRECISIONS: readonly GeoPointPrecision[];
|
|
@@ -214,12 +214,17 @@ export interface RenderOptions {
|
|
|
214
214
|
* so. Absent is LASSO_ROW_CAP.
|
|
215
215
|
* actions - what the host runs on release, in order, by name. Absent is ["select"]; a name the host does
|
|
216
216
|
* not know is skipped, so a list can be sent ahead of the build that understands it.
|
|
217
|
+
* effect - what circling a group does to the PAGE (1.17.0). "filter", the default (absent, or anything that
|
|
218
|
+
* is not exactly "highlight"): the marks inside are published as the selection a click makes, so a
|
|
219
|
+
* page filter bound to the chart sets every circled key and the other charts follow. "highlight":
|
|
220
|
+
* they light inside the chart only, and nothing is published. A host's choice, never the chart's.
|
|
217
221
|
*/
|
|
218
222
|
lasso?: {
|
|
219
223
|
enabled?: boolean;
|
|
220
224
|
rowCap?: number;
|
|
221
225
|
actions?: string[];
|
|
222
226
|
capable?: boolean;
|
|
227
|
+
effect?: "filter" | "highlight";
|
|
223
228
|
};
|
|
224
229
|
}
|
|
225
230
|
/** One reader gesture on a chart's own control. */
|
package/dist/types/host.d.ts
CHANGED
|
@@ -263,6 +263,15 @@ export interface ChartHostConfig {
|
|
|
263
263
|
annotations?: MarkAnnotation[];
|
|
264
264
|
/** A badge was clicked. The mark beneath is not selected. */
|
|
265
265
|
onAnnotationClick?: (annotation: MarkAnnotation) => void;
|
|
266
|
+
/**
|
|
267
|
+
* WHETHER THIS CHART'S SELECTION REACHES ANYTHING OUTSIDE IT - a page filter bound to it, a chart group that
|
|
268
|
+
* cross-filters. Read when a filtering lasso (RenderOptions.lasso.effect "filter", the default) circles a
|
|
269
|
+
* group: false makes the host say once, in the console, that the page gave the chart no filter to set, so the
|
|
270
|
+
* lasso only highlights. Absent: the selection reaches something when anything subscribes to it
|
|
271
|
+
* (selection.onChange, which bindFilter and a group's attach both use). The React binding answers it from
|
|
272
|
+
* `selects` and the group itself. Never throws through: an answer that throws counts as reached.
|
|
273
|
+
*/
|
|
274
|
+
selectionReachesPage?: () => boolean;
|
|
266
275
|
}
|
|
267
276
|
export interface ChartHost {
|
|
268
277
|
/** Replace the notes drawn on marks (see ChartHostConfig.annotations); redraws them at once. */
|