@bicharts/chart-host 0.5.9 → 0.5.10
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/{chunk-L5Y6RLK2.mjs → chunk-OI5SSTYV.mjs} +130 -129
- package/dist/index.mjs +1 -1
- package/dist/react.mjs +1 -1
- package/package.json +1 -1
|
@@ -33,49 +33,49 @@ var COLOR_SCALE_SELF_CLAMP_PCT_MAX = 100;
|
|
|
33
33
|
|
|
34
34
|
// src/defaults.ts
|
|
35
35
|
var clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
|
|
36
|
-
function resolveOptions(
|
|
36
|
+
function resolveOptions(p2) {
|
|
37
37
|
return {
|
|
38
38
|
// ---- host fields: pass through exactly as supplied ----
|
|
39
|
-
width:
|
|
40
|
-
height:
|
|
41
|
-
palette:
|
|
42
|
-
geoUnmatched:
|
|
43
|
-
geo:
|
|
44
|
-
geoPoint:
|
|
45
|
-
maxMapPoints:
|
|
46
|
-
uiState:
|
|
47
|
-
setUiState:
|
|
48
|
-
backgroundColor:
|
|
49
|
-
themeBg:
|
|
50
|
-
themeFg:
|
|
51
|
-
isHighContrast:
|
|
52
|
-
themeAccent:
|
|
53
|
-
cultureCode:
|
|
54
|
-
allowTooltips:
|
|
55
|
-
noDataText:
|
|
56
|
-
onSelect:
|
|
39
|
+
width: p2.width,
|
|
40
|
+
height: p2.height,
|
|
41
|
+
palette: p2.palette,
|
|
42
|
+
geoUnmatched: p2.geoUnmatched,
|
|
43
|
+
geo: p2.geo,
|
|
44
|
+
geoPoint: p2.geoPoint,
|
|
45
|
+
maxMapPoints: p2.maxMapPoints,
|
|
46
|
+
uiState: p2.uiState,
|
|
47
|
+
setUiState: p2.setUiState,
|
|
48
|
+
backgroundColor: p2.backgroundColor,
|
|
49
|
+
themeBg: p2.themeBg,
|
|
50
|
+
themeFg: p2.themeFg,
|
|
51
|
+
isHighContrast: p2.isHighContrast,
|
|
52
|
+
themeAccent: p2.themeAccent,
|
|
53
|
+
cultureCode: p2.cultureCode,
|
|
54
|
+
allowTooltips: p2.allowTooltips,
|
|
55
|
+
noDataText: p2.noDataText,
|
|
56
|
+
onSelect: p2.onSelect,
|
|
57
57
|
// ---- live-restyle knobs: `raw || undefined` / `.toString() || undefined` ----
|
|
58
|
-
colorScaleLow:
|
|
59
|
-
colorScaleHigh:
|
|
58
|
+
colorScaleLow: p2.colorScaleLow || void 0,
|
|
59
|
+
colorScaleHigh: p2.colorScaleHigh || void 0,
|
|
60
60
|
// "" (global, the default), "frame", or "self"; anything else fails open to global.
|
|
61
|
-
colorScaleScope:
|
|
61
|
+
colorScaleScope: p2.colorScaleScope === "frame" || p2.colorScaleScope === "self" ? p2.colorScaleScope : "",
|
|
62
62
|
// Math.max(50, Math.min(100, Number(raw) || 95)) — only meaningful under "self".
|
|
63
|
-
colorScaleSelfClampPct: clamp(Number(
|
|
63
|
+
colorScaleSelfClampPct: clamp(Number(p2.colorScaleSelfClampPct) || COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT, COLOR_SCALE_SELF_CLAMP_PCT_MIN, COLOR_SCALE_SELF_CLAMP_PCT_MAX),
|
|
64
64
|
// Map fills: `raw || undefined` like the colour-scale endpoints. The no-data ->
|
|
65
65
|
// land cascade is left to the chart (so the fallback chain is visible in the
|
|
66
66
|
// generated code); HC substitution has already happened in the caller.
|
|
67
|
-
geoLandColor:
|
|
68
|
-
geoNoDataColor:
|
|
69
|
-
aggregation: (
|
|
67
|
+
geoLandColor: p2.geoLandColor || void 0,
|
|
68
|
+
geoNoDataColor: p2.geoNoDataColor || void 0,
|
|
69
|
+
aggregation: (p2.aggregation == null ? "" : String(p2.aggregation)) || void 0,
|
|
70
70
|
// ---- animation: booleans, default+clamp numerics, "" default enum ----
|
|
71
|
-
animAutoPlay: !!
|
|
71
|
+
animAutoPlay: !!p2.animAutoPlay,
|
|
72
72
|
// Math.max(250, Math.min(5000, Number(raw) || 1000))
|
|
73
|
-
animPlaySpeedMs: clamp(Number(
|
|
73
|
+
animPlaySpeedMs: clamp(Number(p2.animPlaySpeedMs) || ANIM_PLAY_SPEED_DEFAULT, ANIM_PLAY_SPEED_MIN, ANIM_PLAY_SPEED_MAX),
|
|
74
74
|
// Math.max(3, Math.min(500, Number(raw) || 60))
|
|
75
|
-
animMaxIdealFrames: clamp(Number(
|
|
76
|
-
animStopAtEnd: !!
|
|
77
|
-
filtersDuringPlay: !!
|
|
78
|
-
animTimelineStyle: (
|
|
75
|
+
animMaxIdealFrames: clamp(Number(p2.animMaxIdealFrames) || ANIM_MAX_IDEAL_FRAMES_DEFAULT, ANIM_MAX_IDEAL_FRAMES_MIN, ANIM_MAX_IDEAL_FRAMES_MAX),
|
|
76
|
+
animStopAtEnd: !!p2.animStopAtEnd,
|
|
77
|
+
filtersDuringPlay: !!p2.filtersDuringPlay,
|
|
78
|
+
animTimelineStyle: (p2.animTimelineStyle || "").toString()
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -344,16 +344,16 @@ function r3(n) {
|
|
|
344
344
|
if (a2 && o && i3(a2) !== o && (a2 = null), n.city !== void 0 && n.city !== null) {
|
|
345
345
|
let r = u(String(n.city)), l = F[n.mapKind || "north-america"] ?? "N", f = Y(r);
|
|
346
346
|
if (f) {
|
|
347
|
-
let C = n.state === void 0 || n.state === null ? "" : String(n.state).trim(),
|
|
347
|
+
let C = n.state === void 0 || n.state === null ? "" : String(n.state).trim(), d = C ? u(C) : "", p2 = C ? H(C) : null, S = [], R2 = -1;
|
|
348
348
|
for (let s of f) {
|
|
349
349
|
let A = s.row;
|
|
350
350
|
if (!A.kinds.includes(l)) continue;
|
|
351
351
|
let c = 0;
|
|
352
|
-
if (C && A.a1 !== "") if (
|
|
352
|
+
if (C && A.a1 !== "") if (p2 && A.a1 === p2 || u(A.a1) === d) c++;
|
|
353
353
|
else continue;
|
|
354
354
|
if (o) if (I(A.cc) === o) c++;
|
|
355
355
|
else continue;
|
|
356
|
-
c >
|
|
356
|
+
c > R2 ? (R2 = c, S = [s]) : c === R2 && S.push(s);
|
|
357
357
|
}
|
|
358
358
|
S.some((s) => s.primary) && (S = S.filter((s) => s.primary));
|
|
359
359
|
let N2 = /* @__PURE__ */ new Map();
|
|
@@ -382,7 +382,7 @@ function r3(n) {
|
|
|
382
382
|
var U = { latlon: 0, city: 1, zip3: 2, state: 3, country: 4 };
|
|
383
383
|
var V = 8;
|
|
384
384
|
function N3(n, e) {
|
|
385
|
-
let t = new Array(n.length), i = new Array(n.length), o = /* @__PURE__ */ new Set(), a2 = [], r = /* @__PURE__ */ new Set(), l = [], f = /* @__PURE__ */ new Set(), C = [],
|
|
385
|
+
let t = new Array(n.length), i = new Array(n.length), o = /* @__PURE__ */ new Set(), a2 = [], r = /* @__PURE__ */ new Set(), l = [], f = /* @__PURE__ */ new Set(), C = [], d = { latlon: 0, city: 0, zip3: 0, state: 0, country: 0 }, p2 = 0, S = 0, R2 = null;
|
|
386
386
|
for (let s = 0; s < n.length; ++s) {
|
|
387
387
|
let A = n[s], c = r3({ ...A, mapKind: e });
|
|
388
388
|
if (o3(c)) {
|
|
@@ -390,7 +390,7 @@ function N3(n, e) {
|
|
|
390
390
|
let M = E(A);
|
|
391
391
|
M && !f.has(M.toLowerCase()) && (f.add(M.toLowerCase()), C.length < V && C.push(M));
|
|
392
392
|
} else if (c) {
|
|
393
|
-
if (t[s] = c.lat, i[s] = c.lon,
|
|
393
|
+
if (t[s] = c.lat, i[s] = c.lon, p2++, d[c.precision]++, (R2 === null || U[c.precision] > U[R2]) && (R2 = c.precision), U[c.precision] > U.city) {
|
|
394
394
|
let M = E(A);
|
|
395
395
|
M && !r.has(M.toLowerCase()) && (r.add(M.toLowerCase()), l.length < V && l.push(M));
|
|
396
396
|
}
|
|
@@ -401,7 +401,7 @@ function N3(n, e) {
|
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
let N2 = !v() && n.some((s) => s.city !== null && s.city !== void 0 && String(s.city).trim() !== "");
|
|
404
|
-
return { lat: t, lon: i, precision:
|
|
404
|
+
return { lat: t, lon: i, precision: R2, precisionCounts: d, coarseExamples: l, unmatched: a2, ambiguousRows: S, ambiguousExamples: C, matchedRows: p2, totalRows: n.length, ...N2 ? { cityTableMissing: true } : {} };
|
|
405
405
|
}
|
|
406
406
|
function E(n) {
|
|
407
407
|
return [n.city, n.state, n.zip, n.country].filter((e) => e != null && String(e).trim() !== "").map((e) => String(e).trim()).join(", ");
|
|
@@ -414,33 +414,34 @@ function s3(n, e) {
|
|
|
414
414
|
return t.some((o) => o.row.kinds.includes(i));
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
// ../shape-core/dist/chunk-
|
|
417
|
+
// ../shape-core/dist/chunk-3VJWHB2I.mjs
|
|
418
418
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
419
|
-
var
|
|
420
|
-
function
|
|
421
|
-
return n ?
|
|
419
|
+
var rn = /* @__PURE__ */ new Set(["n a", "none", "null", "nil", "unknown", "not applicable", "not available", "not specified", "unspecified", "missing", "blank", "empty", "tbd", "to be determined"]);
|
|
420
|
+
function mn(n) {
|
|
421
|
+
return n ? rn.has(n) : true;
|
|
422
422
|
}
|
|
423
|
-
var
|
|
424
|
-
var
|
|
425
|
-
var
|
|
426
|
-
var
|
|
423
|
+
var j2 = 80;
|
|
424
|
+
var Q2 = [["AL", "Alabama"], ["AK", "Alaska"], ["AZ", "Arizona"], ["AR", "Arkansas"], ["CA", "California"], ["CO", "Colorado"], ["CT", "Connecticut"], ["DE", "Delaware"], ["FL", "Florida"], ["GA", "Georgia"], ["HI", "Hawaii"], ["ID", "Idaho"], ["IL", "Illinois"], ["IN", "Indiana"], ["IA", "Iowa"], ["KS", "Kansas"], ["KY", "Kentucky"], ["LA", "Louisiana"], ["ME", "Maine"], ["MD", "Maryland"], ["MA", "Massachusetts"], ["MI", "Michigan"], ["MN", "Minnesota"], ["MS", "Mississippi"], ["MO", "Missouri"], ["MT", "Montana"], ["NE", "Nebraska"], ["NV", "Nevada"], ["NH", "New Hampshire"], ["NJ", "New Jersey"], ["NM", "New Mexico"], ["NY", "New York"], ["NC", "North Carolina"], ["ND", "North Dakota"], ["OH", "Ohio"], ["OK", "Oklahoma"], ["OR", "Oregon"], ["PA", "Pennsylvania"], ["RI", "Rhode Island"], ["SC", "South Carolina"], ["SD", "South Dakota"], ["TN", "Tennessee"], ["TX", "Texas"], ["UT", "Utah"], ["VT", "Vermont"], ["VA", "Virginia"], ["WA", "Washington"], ["WV", "West Virginia"], ["WI", "Wisconsin"], ["WY", "Wyoming"], ["DC", "District of Columbia"], ["PR", "Puerto Rico"], ["GU", "Guam"], ["VI", "U.S. Virgin Islands"], ["AS", "American Samoa"], ["MP", "Northern Mariana Islands"]];
|
|
425
|
+
var nn = new Set(Q2.map((n) => n[0]));
|
|
426
|
+
var an = { "Ala.": "AL", "Alab.": "AL", "Ariz.": "AZ", "Ark.": "AR", "Calif.": "CA", "Cal.": "CA", "Colo.": "CO", "Col.": "CO", "Conn.": "CT", "Del.": "DE", "Fla.": "FL", "Flor.": "FL", "Ga.": "GA", "Ill.": "IL", "Ind.": "IN", "Kan.": "KS", "Kans.": "KS", "Ky.": "KY", "La.": "LA", "Md.": "MD", "Mass.": "MA", "Mich.": "MI", "Minn.": "MN", "Miss.": "MS", "Mo.": "MO", "Mont.": "MT", "Neb.": "NE", "Nebr.": "NE", "Nev.": "NV", "N.H.": "NH", "N.J.": "NJ", "N.M.": "NM", "N.Mex.": "NM", "N. Mex.": "NM", "N.Y.": "NY", "N.C.": "NC", "N.D.": "ND", "N.Dak.": "ND", "N. Dak.": "ND", "Okla.": "OK", "Ore.": "OR", "Oreg.": "OR", "Pa.": "PA", "Penn.": "PA", "Penna.": "PA", "R.I.": "RI", "S.C.": "SC", "S.D.": "SD", "S.Dak.": "SD", "S. Dak.": "SD", "Tenn.": "TN", "Tex.": "TX", "Vt.": "VT", "Va.": "VA", "Wash.": "WA", "W.Va.": "WV", "W. Va.": "WV", "Wis.": "WI", "Wisc.": "WI", "Wyo.": "WY", "D.C.": "DC", "Wash. D.C.": "DC", "Wash., D.C.": "DC", "P.R.": "PR", "V.I.": "VI" };
|
|
427
|
+
var tn = (() => {
|
|
427
428
|
let n = /* @__PURE__ */ new Map();
|
|
428
|
-
for (let [i, s] of
|
|
429
|
-
n.set(
|
|
430
|
-
for (let [i, s] of Object.entries(
|
|
431
|
-
let o =
|
|
429
|
+
for (let [i, s] of Q2) n.set(p(s), i);
|
|
430
|
+
n.set(p("Washington DC"), "DC"), n.set(p("Washington D.C."), "DC"), n.set(p("US Virgin Islands"), "VI");
|
|
431
|
+
for (let [i, s] of Object.entries(an)) {
|
|
432
|
+
let o = p(i);
|
|
432
433
|
o && !n.has(o) && n.set(o, s);
|
|
433
434
|
}
|
|
434
435
|
return n;
|
|
435
436
|
})();
|
|
436
|
-
var
|
|
437
|
+
var en = /* @__PURE__ */ new Set(["01", "02", "04", "05", "06", "08", "09", "10", "11", "12", "13", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "44", "45", "46", "47", "48", "49", "50", "51", "53", "54", "55", "56", "60", "66", "69", "72", "78"]);
|
|
437
438
|
function E2(n) {
|
|
438
439
|
return n.trim().toUpperCase();
|
|
439
440
|
}
|
|
440
|
-
function
|
|
441
|
+
function p(n) {
|
|
441
442
|
return u(n);
|
|
442
443
|
}
|
|
443
|
-
function
|
|
444
|
+
function Sn(n, i) {
|
|
444
445
|
if (n == null) return null;
|
|
445
446
|
let s = String(n).trim();
|
|
446
447
|
if (s.length === 0) return null;
|
|
@@ -452,23 +453,23 @@ function dn(n, i) {
|
|
|
452
453
|
case "country-iso2":
|
|
453
454
|
return m.get(E2(s)) ?? null;
|
|
454
455
|
case "country-name":
|
|
455
|
-
return Q().get(
|
|
456
|
+
return Q().get(p(s)) ?? null;
|
|
456
457
|
case "us-state-code":
|
|
457
458
|
case "us-state-name": {
|
|
458
459
|
let o = E2(s);
|
|
459
|
-
return
|
|
460
|
+
return nn.has(o) ? o : tn.get(p(s)) ?? null;
|
|
460
461
|
}
|
|
461
462
|
case "us-zip5": {
|
|
462
463
|
let o = /^(\d{5})(-\d{4})?$/.exec(s);
|
|
463
464
|
return o ? o[1] : /^\d{3,4}$/.test(s) ? s.padStart(5, "0") : null;
|
|
464
465
|
}
|
|
465
466
|
case "us-county-fips":
|
|
466
|
-
return /^\d{5}$/.test(s) &&
|
|
467
|
+
return /^\d{5}$/.test(s) && en.has(s.slice(0, 2)) ? s : null;
|
|
467
468
|
default:
|
|
468
469
|
return null;
|
|
469
470
|
}
|
|
470
471
|
}
|
|
471
|
-
function
|
|
472
|
+
function _n(n) {
|
|
472
473
|
switch (n) {
|
|
473
474
|
case "country-iso3":
|
|
474
475
|
case "country-iso2":
|
|
@@ -482,29 +483,29 @@ function Mn(n) {
|
|
|
482
483
|
return false;
|
|
483
484
|
}
|
|
484
485
|
}
|
|
485
|
-
function
|
|
486
|
-
let s = new Array(n.length), o = /* @__PURE__ */ new Set(),
|
|
487
|
-
for (let
|
|
488
|
-
let
|
|
489
|
-
if (s[
|
|
486
|
+
function Dn(n, i) {
|
|
487
|
+
let s = new Array(n.length), o = /* @__PURE__ */ new Set(), A = [], S = 0;
|
|
488
|
+
for (let g2 = 0; g2 < n.length; ++g2) {
|
|
489
|
+
let I3 = Sn(n[g2], i);
|
|
490
|
+
if (s[g2] = I3, I3 !== null) S++;
|
|
490
491
|
else {
|
|
491
|
-
let
|
|
492
|
-
if (
|
|
493
|
-
let m3 = String(
|
|
492
|
+
let h3 = n[g2];
|
|
493
|
+
if (h3 != null) {
|
|
494
|
+
let m3 = String(h3).trim();
|
|
494
495
|
if (m3.length > 0) {
|
|
495
496
|
let N2 = m3.toLowerCase();
|
|
496
|
-
o.has(N2) || (o.add(N2),
|
|
497
|
+
o.has(N2) || (o.add(N2), A.push(m3));
|
|
497
498
|
}
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
}
|
|
501
|
-
return { iso: s, unmatched:
|
|
502
|
+
return { iso: s, unmatched: A, matchedRows: S, totalRows: n.length };
|
|
502
503
|
}
|
|
503
504
|
|
|
504
505
|
// ../shape-core/dist/index.mjs
|
|
505
506
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
506
507
|
var L2 = 2;
|
|
507
|
-
var
|
|
508
|
+
var $2 = 400;
|
|
508
509
|
function w2(r) {
|
|
509
510
|
return !!w(r);
|
|
510
511
|
}
|
|
@@ -513,118 +514,118 @@ function m2(r) {
|
|
|
513
514
|
for (let e of r) {
|
|
514
515
|
if (e == null) continue;
|
|
515
516
|
let i = u(String(e));
|
|
516
|
-
if (!
|
|
517
|
+
if (!mn(i) && !n.has(i) && (n.add(i), n.size >= $2)) break;
|
|
517
518
|
}
|
|
518
519
|
return Array.from(n);
|
|
519
520
|
}
|
|
520
521
|
function h2(r) {
|
|
521
522
|
let n = m2(r);
|
|
522
|
-
if (n.length === 0 ||
|
|
523
|
+
if (n.length === 0 || ht(r) < 96) return false;
|
|
523
524
|
let e = n.filter((a2) => w2(a2) && !H(a2)).length, i = n.filter((a2) => !w2(a2) && !!H(a2)).length;
|
|
524
525
|
return e >= 1 && e >= i;
|
|
525
526
|
}
|
|
526
|
-
var
|
|
527
|
+
var gt = /* @__PURE__ */ new Set(["USA", "CAN", "MEX"]);
|
|
527
528
|
function N(r, n) {
|
|
528
529
|
if (!H(r)) return false;
|
|
529
530
|
let e = w(r);
|
|
530
|
-
return e ? n === "world" ? true :
|
|
531
|
+
return e ? n === "world" ? true : gt.has(e) : false;
|
|
531
532
|
}
|
|
532
|
-
function
|
|
533
|
+
function ht(r) {
|
|
533
534
|
let n = m2(r);
|
|
534
535
|
if (n.length === 0) return 0;
|
|
535
536
|
let e = 0;
|
|
536
537
|
for (let i of n) w2(i) && e++;
|
|
537
538
|
return Math.round(e / n.length * 1e3) / 10;
|
|
538
539
|
}
|
|
539
|
-
function
|
|
540
|
+
function R(r) {
|
|
540
541
|
let n = m2(r);
|
|
541
542
|
if (n.length === 0) return 0;
|
|
542
543
|
let e = 0;
|
|
543
544
|
for (let i of n) H(i) && e++;
|
|
544
545
|
return Math.round(e / n.length * 1e3) / 10;
|
|
545
546
|
}
|
|
546
|
-
function
|
|
547
|
+
function O2(r) {
|
|
547
548
|
let n = /* @__PURE__ */ new Set();
|
|
548
549
|
for (let e of r) {
|
|
549
550
|
if (e == null) continue;
|
|
550
551
|
let i = String(e).trim();
|
|
551
|
-
if (!
|
|
552
|
+
if (!mn(u(i)) && !n.has(i) && (n.add(i), n.size >= $2)) break;
|
|
552
553
|
}
|
|
553
554
|
return Array.from(n);
|
|
554
555
|
}
|
|
555
|
-
function
|
|
556
|
-
let n =
|
|
556
|
+
function B2(r) {
|
|
557
|
+
let n = O2(r);
|
|
557
558
|
if (n.length === 0) return 0;
|
|
558
559
|
let e = 0;
|
|
559
560
|
for (let i of n) x(i).length > 0 && e++;
|
|
560
561
|
return Math.round(e / n.length * 1e3) / 10;
|
|
561
562
|
}
|
|
562
|
-
function
|
|
563
|
+
function Ct(r, n) {
|
|
563
564
|
let e = m2(r);
|
|
564
565
|
if (e.length === 0) return 0;
|
|
565
566
|
let i = 0;
|
|
566
567
|
for (let a2 of e) s3(a2, n) && i++;
|
|
567
568
|
return Math.round(i / e.length * 1e3) / 10;
|
|
568
569
|
}
|
|
569
|
-
function
|
|
570
|
+
function I2(r, n) {
|
|
570
571
|
let e = 0;
|
|
571
572
|
for (let i of m2(r)) n(i) && e++;
|
|
572
573
|
return e;
|
|
573
574
|
}
|
|
574
|
-
function
|
|
575
|
+
function Pt(r, n) {
|
|
575
576
|
let e = 0;
|
|
576
|
-
for (let i of
|
|
577
|
+
for (let i of O2(r)) n(i) && e++;
|
|
577
578
|
return e;
|
|
578
579
|
}
|
|
579
|
-
function
|
|
580
|
-
let a2 = [], g2 = [], o = {}, G2 = new Set(r),
|
|
580
|
+
function Mt(r, n, e, i) {
|
|
581
|
+
let a2 = [], g2 = [], o = {}, G2 = new Set(r), p2 = (t) => n.map((s) => s[t]);
|
|
581
582
|
for (let t of ["city", "zip", "lat", "lon", "country"]) {
|
|
582
583
|
let s = e?.[t];
|
|
583
584
|
s && G2.has(s) && (o[t] = s);
|
|
584
585
|
}
|
|
585
586
|
let l = e?.state;
|
|
586
587
|
if (l && G2.has(l)) {
|
|
587
|
-
let t =
|
|
588
|
-
s.length > 0 && s.every((c) => N(c, i)) ? g2.push(`state=${l} (every value is "CA", which is both Canada and California)`) : h2(t) ? (g2.push(`state=${l} (every value is a country, not a state)`), o.country || (o.country = l)) :
|
|
588
|
+
let t = p2(l), s = m2(t);
|
|
589
|
+
s.length > 0 && s.every((c) => N(c, i)) ? g2.push(`state=${l} (every value is "CA", which is both Canada and California)`) : h2(t) ? (g2.push(`state=${l} (every value is a country, not a state)`), o.country || (o.country = l)) : R(t) < 96 ? g2.push(`state=${l} (only ${R(t)}% of values are states/provinces)`) : o.state = l;
|
|
589
590
|
}
|
|
590
|
-
let
|
|
591
|
+
let d = new Set(Object.values(o).filter(Boolean)), C = r.filter((t) => !d.has(t) && !t.startsWith("__"));
|
|
591
592
|
if (!o.state) {
|
|
592
593
|
let t = null;
|
|
593
594
|
for (let s of C) {
|
|
594
|
-
let c =
|
|
595
|
+
let c = p2(s);
|
|
595
596
|
if (h2(c)) continue;
|
|
596
|
-
let u2 =
|
|
597
|
-
if (u2 <
|
|
598
|
-
let S =
|
|
599
|
-
S < L2 &&
|
|
597
|
+
let u2 = R(c);
|
|
598
|
+
if (u2 < 96) continue;
|
|
599
|
+
let S = I2(c, (P2) => !!H(P2)), E3 = I2(c, (P2) => !!H(P2) && !N(P2, i));
|
|
600
|
+
S < L2 && E3 < 1 || (!t || u2 > t.pct) && (t = { name: s, pct: u2 });
|
|
600
601
|
}
|
|
601
|
-
t && (o.state = t.name,
|
|
602
|
+
t && (o.state = t.name, d.add(t.name), a2.push(`state=${t.name} (${t.pct}% states/provinces)`));
|
|
602
603
|
}
|
|
603
604
|
if (!o.zip) for (let t of C) {
|
|
604
|
-
if (
|
|
605
|
-
let s =
|
|
606
|
-
if (!(c <
|
|
607
|
-
o.zip = t,
|
|
605
|
+
if (d.has(t)) continue;
|
|
606
|
+
let s = p2(t), c = B2(s);
|
|
607
|
+
if (!(c < 96) && !(Pt(s, (u2) => x(u2).length > 0) < L2)) {
|
|
608
|
+
o.zip = t, d.add(t), a2.push(`zip=${t} (${c}% ZIP codes)`);
|
|
608
609
|
break;
|
|
609
610
|
}
|
|
610
611
|
}
|
|
611
612
|
if (!o.country) {
|
|
612
|
-
for (let t of C) if (!
|
|
613
|
-
o.country = t,
|
|
613
|
+
for (let t of C) if (!d.has(t) && h2(p2(t))) {
|
|
614
|
+
o.country = t, d.add(t), a2.push(`country=${t}`);
|
|
614
615
|
break;
|
|
615
616
|
}
|
|
616
617
|
}
|
|
617
618
|
if (!o.city) {
|
|
618
619
|
let t = null;
|
|
619
620
|
for (let s of C) {
|
|
620
|
-
if (
|
|
621
|
-
let c =
|
|
622
|
-
u2 <
|
|
621
|
+
if (d.has(s)) continue;
|
|
622
|
+
let c = p2(s), u2 = Ct(c, i);
|
|
623
|
+
u2 < j2 || I2(c, (S) => s3(S, i)) < L2 || (!t || u2 > t.pct) && (t = { name: s, pct: u2 });
|
|
623
624
|
}
|
|
624
625
|
t && (o.city = t.name, a2.push(`city=${t.name} (${t.pct}% known cities)`));
|
|
625
626
|
}
|
|
626
|
-
let
|
|
627
|
-
return o.country && !z2 && !(o.city || o.state || o.zip || o.lat && o.lon) && g2.push(
|
|
627
|
+
let _2 = o.country ? p2(o.country) : [], v2 = !!o.country && h2(_2), D = v2 ? new Set(_2.map((t) => w(t == null ? null : String(t))).filter(Boolean)).size : 0, z2 = v2 && D >= 2;
|
|
628
|
+
return o.country && !z2 && !(o.city || o.state || o.zip || o.lat && o.lon) && g2.push(v2 ? `country=${o.country} (every row resolves to the same country - nothing to place apart)` : `country=${o.country} (values are not country identifiers)`), { bind: !!(o.city || o.state || o.zip || z2 || o.lat && o.lon) ? o : null, backfilled: a2, refused: g2 };
|
|
628
629
|
}
|
|
629
630
|
|
|
630
631
|
// src/payload.ts
|
|
@@ -638,21 +639,21 @@ function buildRenderPayload(cols, rowObjs, geo, point) {
|
|
|
638
639
|
let rolesRefused = [];
|
|
639
640
|
if (bind) {
|
|
640
641
|
const dims = cols.filter((c) => !c.isMeasure).map((c) => c.name);
|
|
641
|
-
const res =
|
|
642
|
+
const res = Mt(dims, rowObjs, bind, point?.mapKind);
|
|
642
643
|
bind = res.bind;
|
|
643
644
|
rolesBackfilled = res.backfilled;
|
|
644
645
|
rolesRefused = res.refused;
|
|
645
646
|
}
|
|
646
647
|
const hasPointBind = !!bind && !!(bind.city || bind.state || bind.zip || bind.country || bind.lat && bind.lon);
|
|
647
648
|
if (hasPointBind) {
|
|
648
|
-
const
|
|
649
|
+
const p2 = bind;
|
|
649
650
|
const built = N3(rowObjs.map((r) => ({
|
|
650
|
-
lat:
|
|
651
|
-
lon:
|
|
652
|
-
city:
|
|
653
|
-
state:
|
|
654
|
-
zip:
|
|
655
|
-
country:
|
|
651
|
+
lat: p2.lat ? r[p2.lat] : null,
|
|
652
|
+
lon: p2.lon ? r[p2.lon] : null,
|
|
653
|
+
city: p2.city ? r[p2.city] : null,
|
|
654
|
+
state: p2.state ? r[p2.state] : null,
|
|
655
|
+
zip: p2.zip ? r[p2.zip] : null,
|
|
656
|
+
country: p2.country ? r[p2.country] : null
|
|
656
657
|
})), point?.mapKind);
|
|
657
658
|
pLat = built.lat;
|
|
658
659
|
pLon = built.lon;
|
|
@@ -679,8 +680,8 @@ function buildRenderPayload(cols, rowObjs, geo, point) {
|
|
|
679
680
|
let geoIso = null;
|
|
680
681
|
let geoUnmatched;
|
|
681
682
|
let geoUnmatchedDistinct;
|
|
682
|
-
if (geo && geo.column && geo.kind &&
|
|
683
|
-
const built =
|
|
683
|
+
if (geo && geo.column && geo.kind && _n(geo.kind)) {
|
|
684
|
+
const built = Dn(rowObjs.map((r) => r[geo.column]), geo.kind);
|
|
684
685
|
geoIso = built.iso;
|
|
685
686
|
geoUnmatched = { count: built.totalRows - built.matchedRows, examples: built.unmatched.slice(0, 8) };
|
|
686
687
|
geoUnmatchedDistinct = built.unmatched.length;
|
|
@@ -691,11 +692,11 @@ function buildRenderPayload(cols, rowObjs, geo, point) {
|
|
|
691
692
|
const row = rowObjs[r];
|
|
692
693
|
const a2 = new Array(cols.length + extra);
|
|
693
694
|
for (let c = 0; c < cols.length; c++) {
|
|
694
|
-
const
|
|
695
|
-
if (
|
|
696
|
-
a2[c] =
|
|
695
|
+
const v2 = row[colNames[c]];
|
|
696
|
+
if (v2 instanceof Date) {
|
|
697
|
+
a2[c] = v2.toISOString();
|
|
697
698
|
} else {
|
|
698
|
-
a2[c] =
|
|
699
|
+
a2[c] = v2 ?? null;
|
|
699
700
|
}
|
|
700
701
|
}
|
|
701
702
|
let k2 = cols.length;
|
|
@@ -751,8 +752,8 @@ function createMarkResolver(env) {
|
|
|
751
752
|
const pt = el.getPointAtLength(L3 * i / N2);
|
|
752
753
|
const dx = m3.a * pt.x + m3.c * pt.y + m3.e - x2;
|
|
753
754
|
const dy = m3.b * pt.x + m3.d * pt.y + m3.f - y2;
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
755
|
+
const d = dx * dx + dy * dy;
|
|
756
|
+
if (d < best) best = d;
|
|
756
757
|
}
|
|
757
758
|
return Math.sqrt(best);
|
|
758
759
|
};
|
|
@@ -773,9 +774,9 @@ function createMarkResolver(env) {
|
|
|
773
774
|
let best = mark;
|
|
774
775
|
let bestD = Number.MAX_VALUE;
|
|
775
776
|
for (const el of candidates) {
|
|
776
|
-
const
|
|
777
|
-
if (
|
|
778
|
-
bestD =
|
|
777
|
+
const d = distToPathCenterline(el, x2, y2);
|
|
778
|
+
if (d < bestD) {
|
|
779
|
+
bestD = d;
|
|
779
780
|
best = el;
|
|
780
781
|
}
|
|
781
782
|
}
|
|
@@ -932,7 +933,7 @@ function createChartHost(container, config) {
|
|
|
932
933
|
let data = config.data;
|
|
933
934
|
{
|
|
934
935
|
const stamped = config.data?.meta?.hostContract;
|
|
935
|
-
const major = (
|
|
936
|
+
const major = (v2) => (v2 || "").split(".")[0];
|
|
936
937
|
if (stamped && major(stamped) !== major(HOST_CONTRACT_VERSION)) {
|
|
937
938
|
try {
|
|
938
939
|
(win?.console ?? console)?.warn(
|
|
@@ -985,8 +986,8 @@ function createChartHost(container, config) {
|
|
|
985
986
|
const marks = container.querySelectorAll(`.${MARK_CLASS}[${ROW_IDX_ATTR}], .${LEGEND_MARK_CLASS}[${ROW_IDX_ATTR}]`);
|
|
986
987
|
for (const m3 of Array.from(marks)) {
|
|
987
988
|
const rows = parseRowIdxs(m3.getAttribute(ROW_IDX_ATTR));
|
|
988
|
-
const
|
|
989
|
-
m3.classList?.[
|
|
989
|
+
const on = active && rows.some((r) => wanted.has(r));
|
|
990
|
+
m3.classList?.[on ? "add" : "remove"](MARK_SELECTED_CLASS);
|
|
990
991
|
}
|
|
991
992
|
} catch {
|
|
992
993
|
}
|
|
@@ -1004,10 +1005,10 @@ function createChartHost(container, config) {
|
|
|
1004
1005
|
let xfAt = 0;
|
|
1005
1006
|
const XF_ECHO_MS = 150;
|
|
1006
1007
|
const onXf = (e) => {
|
|
1007
|
-
const
|
|
1008
|
+
const d = e?.detail || {};
|
|
1008
1009
|
xfAt = Date.now();
|
|
1009
|
-
if (
|
|
1010
|
-
else if (
|
|
1010
|
+
if (d.clear) notify([], d.source || "chart");
|
|
1011
|
+
else if (d.mark) notify(parseRowIdxs(d.mark.getAttribute?.(ROW_IDX_ATTR)), d.source || "chart");
|
|
1011
1012
|
};
|
|
1012
1013
|
const resolver = createMarkResolver({
|
|
1013
1014
|
root: container,
|
package/dist/index.mjs
CHANGED
package/dist/react.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
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",
|