@bicharts/chart-host 0.1.7 → 0.1.8
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.
|
@@ -749,7 +749,11 @@ function distinctNormalized(values) {
|
|
|
749
749
|
function looksLikeCountryColumn(values) {
|
|
750
750
|
const d = distinctNormalized(values);
|
|
751
751
|
if (d.length === 0) return false;
|
|
752
|
-
|
|
752
|
+
if (!d.every((v) => COUNTRY_IDS.has(v))) return false;
|
|
753
|
+
return d.some((v) => !resolveAdmin1(v));
|
|
754
|
+
}
|
|
755
|
+
function isAmbiguousCountryState(normalized) {
|
|
756
|
+
return COUNTRY_IDS.has(normalized) && !!resolveAdmin1(normalized);
|
|
753
757
|
}
|
|
754
758
|
function admin1MatchPct(values) {
|
|
755
759
|
const d = distinctNormalized(values);
|
|
@@ -808,7 +812,10 @@ function resolvePointRoles(columns, rows, hint) {
|
|
|
808
812
|
const hintedState = hint?.state;
|
|
809
813
|
if (hintedState && colSet.has(hintedState)) {
|
|
810
814
|
const vals = valuesOf(hintedState);
|
|
811
|
-
|
|
815
|
+
const dvals = distinctNormalized(vals);
|
|
816
|
+
if (dvals.length > 0 && dvals.every(isAmbiguousCountryState)) {
|
|
817
|
+
refused.push(`state=${hintedState} (every value is "CA", which is both Canada and California)`);
|
|
818
|
+
} else if (looksLikeCountryColumn(vals)) {
|
|
812
819
|
refused.push(`state=${hintedState} (every value is a country, not a state)`);
|
|
813
820
|
if (!out.country) out.country = hintedState;
|
|
814
821
|
} else if (admin1MatchPct(vals) < THRESHOLD_PCT) {
|
|
@@ -826,7 +833,9 @@ function resolvePointRoles(columns, rows, hint) {
|
|
|
826
833
|
if (looksLikeCountryColumn(vals)) continue;
|
|
827
834
|
const pct = admin1MatchPct(vals);
|
|
828
835
|
if (pct < THRESHOLD_PCT) continue;
|
|
829
|
-
|
|
836
|
+
const hits = distinctMatches(vals, (v) => !!resolveAdmin1(v));
|
|
837
|
+
const unambiguous = distinctMatches(vals, (v) => !!resolveAdmin1(v) && !isAmbiguousCountryState(v));
|
|
838
|
+
if (hits < MIN_DISTINCT_BACKFILL && unambiguous < 1) continue;
|
|
830
839
|
if (!best || pct > best.pct) best = { name: c, pct };
|
|
831
840
|
}
|
|
832
841
|
if (best) {
|
|
@@ -1392,4 +1401,4 @@ export {
|
|
|
1392
1401
|
compileRenderFn,
|
|
1393
1402
|
createChartHost
|
|
1394
1403
|
};
|
|
1395
|
-
//# sourceMappingURL=chunk-
|
|
1404
|
+
//# sourceMappingURL=chunk-LWVJSMWU.mjs.map
|