@bicharts/chart-host 0.6.103 → 0.6.106
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/card.mjs +2 -2
- package/dist/chunk-5WTQN5DL.mjs +96 -0
- package/dist/{chunk-4BR6VJQX.mjs → chunk-K6UXTDMR.mjs} +40 -100
- package/dist/{chunk-D6A37G2G.mjs → chunk-MU4BWWO6.mjs} +10 -10
- package/dist/{chunk-CNT3QA3R.mjs → chunk-SYUJ4TPX.mjs} +961 -771
- package/dist/index.mjs +22 -15
- package/dist/provinces.mjs +229 -0
- package/dist/react.mjs +6 -4
- package/dist/types/admin1LookupLoader.d.ts +26 -0
- package/dist/types/contract.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/optionsVocabulary.d.ts +5 -0
- package/dist/types/payload.d.ts +63 -4
- package/dist/types/provinceGeo.d.ts +38 -0
- package/dist/types/provinceHost.d.ts +47 -0
- package/dist/types/provinces.d.ts +3 -0
- package/dist/zoom-memory.mjs +1 -1
- package/package.json +6 -1
package/dist/card.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
|
computeSelectionCard
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-MU4BWWO6.mjs";
|
|
5
|
+
import "./chunk-SYUJ4TPX.mjs";
|
|
6
6
|
import "./chunk-GHODWOAL.mjs";
|
|
7
7
|
|
|
8
8
|
// src/selectionCardChrome.ts
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
import {
|
|
3
|
+
NA_ISO3,
|
|
4
|
+
NA_LAT_MAX,
|
|
5
|
+
clipFeatureToLat
|
|
6
|
+
} from "./chunk-A2GMXZP7.mjs";
|
|
7
|
+
|
|
8
|
+
// src/geoLazy.ts
|
|
9
|
+
var byKind = /* @__PURE__ */ new Map();
|
|
10
|
+
var byAsset = /* @__PURE__ */ new Map();
|
|
11
|
+
var _na;
|
|
12
|
+
function geoAssetFor(geoKind) {
|
|
13
|
+
if (!geoKind) return null;
|
|
14
|
+
const k = geoKind.toLowerCase();
|
|
15
|
+
if (/^country/.test(k)) return "world";
|
|
16
|
+
if (k === "north-america") return "world";
|
|
17
|
+
if (k === "world") return "world";
|
|
18
|
+
if (k === "us-state-code" || k === "us-state-name") return "us-states";
|
|
19
|
+
if (k === "us-zip5") return "us-zip3";
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
var _worldBase;
|
|
23
|
+
function worldBasemap(world) {
|
|
24
|
+
if (!_worldBase) {
|
|
25
|
+
_worldBase = {
|
|
26
|
+
type: "FeatureCollection",
|
|
27
|
+
features: world.features.filter((f) => f?.geometry && f.geometry.type !== "Point")
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return _worldBase;
|
|
31
|
+
}
|
|
32
|
+
function northAmerica(world) {
|
|
33
|
+
if (!_na) {
|
|
34
|
+
_na = {
|
|
35
|
+
type: "FeatureCollection",
|
|
36
|
+
features: world.features.filter((f) => NA_ISO3.has(f?.id) && f?.geometry && f.geometry.type !== "Point").map((f) => clipFeatureToLat(f, NA_LAT_MAX)).filter((f) => f !== null)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return _na;
|
|
40
|
+
}
|
|
41
|
+
function fromAssets(key) {
|
|
42
|
+
const asset = geoAssetFor(key);
|
|
43
|
+
if (!asset) return void 0;
|
|
44
|
+
const geo = byAsset.get(asset);
|
|
45
|
+
if (!geo) return void 0;
|
|
46
|
+
if (key === "north-america") return northAmerica(geo);
|
|
47
|
+
if (key === "world") return worldBasemap(geo);
|
|
48
|
+
return geo;
|
|
49
|
+
}
|
|
50
|
+
async function loadGeo(geoKind) {
|
|
51
|
+
if (!geoKind) return void 0;
|
|
52
|
+
const key = geoKind.toLowerCase();
|
|
53
|
+
const already = geoFromCache(key);
|
|
54
|
+
if (already) return already;
|
|
55
|
+
const asset = geoAssetFor(key);
|
|
56
|
+
if (!asset) return void 0;
|
|
57
|
+
if (asset === "us-states") {
|
|
58
|
+
byAsset.set(asset, (await import("./geoUsStates.generated-JEFM6OHO.mjs")).US_STATES);
|
|
59
|
+
} else if (asset === "us-zip3") {
|
|
60
|
+
byAsset.set(asset, (await import("./geoUsZip3.generated-VSWL7D6F.mjs")).US_ZIP3);
|
|
61
|
+
} else {
|
|
62
|
+
byAsset.set(asset, (await import("./geoWorld110m.generated-TD2TA7S7.mjs")).WORLD_110M);
|
|
63
|
+
}
|
|
64
|
+
return fromAssets(key);
|
|
65
|
+
}
|
|
66
|
+
function geoFromCache(geoKind) {
|
|
67
|
+
if (!geoKind) return void 0;
|
|
68
|
+
const key = geoKind.toLowerCase();
|
|
69
|
+
return byKind.get(key) ?? fromAssets(key);
|
|
70
|
+
}
|
|
71
|
+
function registerGeo(geoKind, geo) {
|
|
72
|
+
if (geoKind && geo) byKind.set(geoKind.toLowerCase(), geo);
|
|
73
|
+
}
|
|
74
|
+
function registerGeoAsset(asset, geo) {
|
|
75
|
+
if (!asset || !geo) return;
|
|
76
|
+
byAsset.set(asset, geo);
|
|
77
|
+
if (asset === "world") {
|
|
78
|
+
_na = void 0;
|
|
79
|
+
_worldBase = void 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function clearGeoCache() {
|
|
83
|
+
byKind.clear();
|
|
84
|
+
byAsset.clear();
|
|
85
|
+
_na = void 0;
|
|
86
|
+
_worldBase = void 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
geoAssetFor,
|
|
91
|
+
loadGeo,
|
|
92
|
+
geoFromCache,
|
|
93
|
+
registerGeo,
|
|
94
|
+
registerGeoAsset,
|
|
95
|
+
clearGeoCache
|
|
96
|
+
};
|
|
@@ -34,18 +34,16 @@ import {
|
|
|
34
34
|
unpinScrolledAxis
|
|
35
35
|
} from "./chunk-IE7TM6DX.mjs";
|
|
36
36
|
import {
|
|
37
|
+
geoFromCache
|
|
38
|
+
} from "./chunk-5WTQN5DL.mjs";
|
|
39
|
+
import {
|
|
40
|
+
Dt,
|
|
37
41
|
Fn,
|
|
38
|
-
J3,
|
|
39
42
|
Q,
|
|
43
|
+
Rr,
|
|
40
44
|
Yn,
|
|
41
|
-
ir,
|
|
42
45
|
tt
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import {
|
|
45
|
-
NA_ISO3,
|
|
46
|
-
NA_LAT_MAX,
|
|
47
|
-
clipFeatureToLat
|
|
48
|
-
} from "./chunk-A2GMXZP7.mjs";
|
|
46
|
+
} from "./chunk-SYUJ4TPX.mjs";
|
|
49
47
|
import {
|
|
50
48
|
ACTIVE_TICK_CLASS,
|
|
51
49
|
ANIM_LOOP_DELAY_DEFAULT,
|
|
@@ -1167,6 +1165,8 @@ function resolveOptions(p) {
|
|
|
1167
1165
|
// generated code); HC substitution has already happened in the caller.
|
|
1168
1166
|
geoLandColor: p.geoLandColor || themedLand(p) || void 0,
|
|
1169
1167
|
geoNoDataColor: p.geoNoDataColor || void 0,
|
|
1168
|
+
// Borders on unless the host says false: a province map of several countries needs them to read.
|
|
1169
|
+
geoBorders: p.geoBorders !== false,
|
|
1170
1170
|
aggregation: (p.aggregation == null ? "" : String(p.aggregation)) || void 0,
|
|
1171
1171
|
// A recognised value wins, anything else falls to the default: an unknown string must
|
|
1172
1172
|
// never reach a chart as a live mode. Both of these are read on EVERY render, so a
|
|
@@ -1269,87 +1269,6 @@ function resolveOptions(p) {
|
|
|
1269
1269
|
};
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
|
-
// src/geoLazy.ts
|
|
1273
|
-
var byKind = /* @__PURE__ */ new Map();
|
|
1274
|
-
var byAsset = /* @__PURE__ */ new Map();
|
|
1275
|
-
var _na;
|
|
1276
|
-
function geoAssetFor(geoKind) {
|
|
1277
|
-
if (!geoKind) return null;
|
|
1278
|
-
const k = geoKind.toLowerCase();
|
|
1279
|
-
if (/^country/.test(k)) return "world";
|
|
1280
|
-
if (k === "north-america") return "world";
|
|
1281
|
-
if (k === "world") return "world";
|
|
1282
|
-
if (k === "us-state-code" || k === "us-state-name") return "us-states";
|
|
1283
|
-
if (k === "us-zip5") return "us-zip3";
|
|
1284
|
-
return null;
|
|
1285
|
-
}
|
|
1286
|
-
var _worldBase;
|
|
1287
|
-
function worldBasemap(world) {
|
|
1288
|
-
if (!_worldBase) {
|
|
1289
|
-
_worldBase = {
|
|
1290
|
-
type: "FeatureCollection",
|
|
1291
|
-
features: world.features.filter((f2) => f2?.geometry && f2.geometry.type !== "Point")
|
|
1292
|
-
};
|
|
1293
|
-
}
|
|
1294
|
-
return _worldBase;
|
|
1295
|
-
}
|
|
1296
|
-
function northAmerica(world) {
|
|
1297
|
-
if (!_na) {
|
|
1298
|
-
_na = {
|
|
1299
|
-
type: "FeatureCollection",
|
|
1300
|
-
features: world.features.filter((f2) => NA_ISO3.has(f2?.id) && f2?.geometry && f2.geometry.type !== "Point").map((f2) => clipFeatureToLat(f2, NA_LAT_MAX)).filter((f2) => f2 !== null)
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
return _na;
|
|
1304
|
-
}
|
|
1305
|
-
function fromAssets(key) {
|
|
1306
|
-
const asset = geoAssetFor(key);
|
|
1307
|
-
if (!asset) return void 0;
|
|
1308
|
-
const geo = byAsset.get(asset);
|
|
1309
|
-
if (!geo) return void 0;
|
|
1310
|
-
if (key === "north-america") return northAmerica(geo);
|
|
1311
|
-
if (key === "world") return worldBasemap(geo);
|
|
1312
|
-
return geo;
|
|
1313
|
-
}
|
|
1314
|
-
async function loadGeo(geoKind) {
|
|
1315
|
-
if (!geoKind) return void 0;
|
|
1316
|
-
const key = geoKind.toLowerCase();
|
|
1317
|
-
const already = geoFromCache(key);
|
|
1318
|
-
if (already) return already;
|
|
1319
|
-
const asset = geoAssetFor(key);
|
|
1320
|
-
if (!asset) return void 0;
|
|
1321
|
-
if (asset === "us-states") {
|
|
1322
|
-
byAsset.set(asset, (await import("./geoUsStates.generated-JEFM6OHO.mjs")).US_STATES);
|
|
1323
|
-
} else if (asset === "us-zip3") {
|
|
1324
|
-
byAsset.set(asset, (await import("./geoUsZip3.generated-VSWL7D6F.mjs")).US_ZIP3);
|
|
1325
|
-
} else {
|
|
1326
|
-
byAsset.set(asset, (await import("./geoWorld110m.generated-TD2TA7S7.mjs")).WORLD_110M);
|
|
1327
|
-
}
|
|
1328
|
-
return fromAssets(key);
|
|
1329
|
-
}
|
|
1330
|
-
function geoFromCache(geoKind) {
|
|
1331
|
-
if (!geoKind) return void 0;
|
|
1332
|
-
const key = geoKind.toLowerCase();
|
|
1333
|
-
return byKind.get(key) ?? fromAssets(key);
|
|
1334
|
-
}
|
|
1335
|
-
function registerGeo(geoKind, geo) {
|
|
1336
|
-
if (geoKind && geo) byKind.set(geoKind.toLowerCase(), geo);
|
|
1337
|
-
}
|
|
1338
|
-
function registerGeoAsset(asset, geo) {
|
|
1339
|
-
if (!asset || !geo) return;
|
|
1340
|
-
byAsset.set(asset, geo);
|
|
1341
|
-
if (asset === "world") {
|
|
1342
|
-
_na = void 0;
|
|
1343
|
-
_worldBase = void 0;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
function clearGeoCache() {
|
|
1347
|
-
byKind.clear();
|
|
1348
|
-
byAsset.clear();
|
|
1349
|
-
_na = void 0;
|
|
1350
|
-
_worldBase = void 0;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
1272
|
// src/payload.ts
|
|
1354
1273
|
var ROW_IDX_COLUMN = "__rowIdx__";
|
|
1355
1274
|
function resolvePointChannel(cols, rowObjs, point) {
|
|
@@ -1363,7 +1282,7 @@ function resolvePointChannel(cols, rowObjs, point) {
|
|
|
1363
1282
|
let labelCol;
|
|
1364
1283
|
if (bind) {
|
|
1365
1284
|
const dims = cols.filter((c) => !c.isMeasure).map((c) => c.name);
|
|
1366
|
-
const res =
|
|
1285
|
+
const res = Rr(dims, rowObjs, bind, point?.mapKind, cols.map((c) => c.name));
|
|
1367
1286
|
bind = res.bind;
|
|
1368
1287
|
rolesBackfilled = res.backfilled;
|
|
1369
1288
|
rolesRefused = res.refused;
|
|
@@ -1373,7 +1292,7 @@ function resolvePointChannel(cols, rowObjs, point) {
|
|
|
1373
1292
|
const hasPointBind = !!bind && !!(bind.city || bind.state || bind.zip || bind.country || bind.lat && bind.lon);
|
|
1374
1293
|
if (hasPointBind) {
|
|
1375
1294
|
const p = bind;
|
|
1376
|
-
const built =
|
|
1295
|
+
const built = Dt(rowObjs.map((r) => ({
|
|
1377
1296
|
lat: p.lat ? r[p.lat] : null,
|
|
1378
1297
|
lon: p.lon ? r[p.lon] : null,
|
|
1379
1298
|
city: p.city ? r[p.city] : null,
|
|
@@ -1381,7 +1300,7 @@ function resolvePointChannel(cols, rowObjs, point) {
|
|
|
1381
1300
|
zip: p.zip ? r[p.zip] : null,
|
|
1382
1301
|
country: p.country ? r[p.country] : null,
|
|
1383
1302
|
label: labelCol ? r[labelCol] : null
|
|
1384
|
-
})), point?.mapKind);
|
|
1303
|
+
})), point?.mapKind, point?.region ?? null);
|
|
1385
1304
|
pLat = built.lat;
|
|
1386
1305
|
pLon = built.lon;
|
|
1387
1306
|
pPrec = built.precisions;
|
|
@@ -1431,7 +1350,29 @@ function buildRenderPayload(cols, rowObjs, geo, point, destination, opts) {
|
|
|
1431
1350
|
let geoIso = null;
|
|
1432
1351
|
let geoUnmatched;
|
|
1433
1352
|
let geoUnmatchedDistinct;
|
|
1434
|
-
|
|
1353
|
+
let geoProvince;
|
|
1354
|
+
if (geo && geo.column && geo.grain && geo.grain.toLowerCase() === "admin1" && geo.join) {
|
|
1355
|
+
const kind = (geo.kind || "").toLowerCase();
|
|
1356
|
+
const fb = geo.fallback ?? {};
|
|
1357
|
+
const isProvince = kind.startsWith("admin1-") || kind.startsWith("us-state-");
|
|
1358
|
+
const latCol = kind === "latlon" ? geo.column : fb.lat ?? null;
|
|
1359
|
+
const lonCol = fb.lon ?? (latCol ? longitudeBeside(cols.map((c) => c.name)) : null);
|
|
1360
|
+
const cityCol = kind.startsWith("city") ? geo.column : fb.city ?? null;
|
|
1361
|
+
const locate = geo.locate ?? void 0;
|
|
1362
|
+
const built = geo.join(rowObjs.map((r) => ({
|
|
1363
|
+
province: isProvince ? r[geo.column] : void 0,
|
|
1364
|
+
city: cityCol ? r[cityCol] : void 0,
|
|
1365
|
+
country: fb.country ? r[fb.country] : void 0,
|
|
1366
|
+
lat: latCol ? r[latCol] : void 0,
|
|
1367
|
+
lon: lonCol ? r[lonCol] : void 0
|
|
1368
|
+
})), { provinceKind: isProvince ? kind : null, deriveProvinces: geo.deriveProvinces, locate: locate ?? void 0 });
|
|
1369
|
+
geoIso = built.iso;
|
|
1370
|
+
geoUnmatched = { count: built.totalRows - built.matchedRows, examples: built.unmatched.slice(0, 8) };
|
|
1371
|
+
geoUnmatchedDistinct = built.unmatched.length;
|
|
1372
|
+
const sources = { province: 0, coordinates: 0, city: 0 };
|
|
1373
|
+
for (const s of built.source) if (s) sources[s]++;
|
|
1374
|
+
geoProvince = { sources, ambiguousRows: built.ambiguousRows, ambiguousExamples: built.ambiguousExamples, unplacedPoints: built.unplacedPoints };
|
|
1375
|
+
} else if (geo && geo.column && geo.kind && Yn(geo.kind)) {
|
|
1435
1376
|
const built = Fn(rowObjs.map((r) => r[geo.column]), geo.kind);
|
|
1436
1377
|
geoIso = built.iso;
|
|
1437
1378
|
geoUnmatched = { count: built.totalRows - built.matchedRows, examples: built.unmatched.slice(0, 8) };
|
|
@@ -1512,9 +1453,14 @@ function buildRenderPayload(cols, rowObjs, geo, point, destination, opts) {
|
|
|
1512
1453
|
// the ordinary case adds no bytes.
|
|
1513
1454
|
...rolesRefused.length ? { geoPointRefused: rolesRefused } : {},
|
|
1514
1455
|
...utcDayColumns ? { dateCellsAreUtcDays: true, utcDayColumns } : {},
|
|
1515
|
-
...utcWallClockColumns ? { dateCellsAreUtcWallClock: true, utcWallClockColumns } : {}
|
|
1456
|
+
...utcWallClockColumns ? { dateCellsAreUtcWallClock: true, utcWallClockColumns } : {},
|
|
1457
|
+
...geoProvince ? { geoProvince } : {}
|
|
1516
1458
|
};
|
|
1517
1459
|
}
|
|
1460
|
+
function longitudeBeside(names) {
|
|
1461
|
+
const words = (n) => n.replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-zÀ-ɏ]+/);
|
|
1462
|
+
return names.find((n) => words(n).some((w) => w === "lon" || w === "lng" || w === "long" || w === "longitude")) ?? null;
|
|
1463
|
+
}
|
|
1518
1464
|
|
|
1519
1465
|
// src/codeComments.ts
|
|
1520
1466
|
function stripJsComments(code) {
|
|
@@ -3844,12 +3790,6 @@ export {
|
|
|
3844
3790
|
exportTableService,
|
|
3845
3791
|
browserSaveFile,
|
|
3846
3792
|
resolveOptions,
|
|
3847
|
-
geoAssetFor,
|
|
3848
|
-
loadGeo,
|
|
3849
|
-
geoFromCache,
|
|
3850
|
-
registerGeo,
|
|
3851
|
-
registerGeoAsset,
|
|
3852
|
-
clearGeoCache,
|
|
3853
3793
|
buildRenderPayload,
|
|
3854
3794
|
stripJsComments,
|
|
3855
3795
|
censusMarks,
|
|
@@ -1,12 +1,12 @@
|
|
|
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
|
+
Bt,
|
|
4
|
+
Gt,
|
|
5
|
+
Ii,
|
|
6
|
+
Ti,
|
|
4
7
|
j,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
u,
|
|
8
|
-
vt
|
|
9
|
-
} from "./chunk-CNT3QA3R.mjs";
|
|
8
|
+
u
|
|
9
|
+
} from "./chunk-SYUJ4TPX.mjs";
|
|
10
10
|
|
|
11
11
|
// src/sourceDateFormat.ts
|
|
12
12
|
function formatSourceDate(raw, opts = {}) {
|
|
@@ -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 Bt(col).suppressed;
|
|
439
439
|
}
|
|
440
440
|
function resolveAgg(col, requested, auto) {
|
|
441
441
|
const fallback = () => {
|
|
442
|
-
const d =
|
|
442
|
+
const d = Ti(col);
|
|
443
443
|
return d === "first" ? "count" : d;
|
|
444
444
|
};
|
|
445
445
|
if (auto) return fallback();
|
|
446
|
-
return
|
|
446
|
+
return Gt(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 (Ii(col, colAgg) && value != null) {
|
|
550
550
|
const allVals = [];
|
|
551
551
|
const allRaw = [];
|
|
552
552
|
for (let r = 0; r < rows.length; r++) {
|