@datawheel/data-explorer 0.3.11 → 0.3.12
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/main.d.mts +2 -0
- package/dist/main.mjs +15 -1
- package/package.json +1 -1
package/dist/main.d.mts
CHANGED
package/dist/main.mjs
CHANGED
|
@@ -1853,6 +1853,9 @@ init_esm_shims();
|
|
|
1853
1853
|
|
|
1854
1854
|
// src/state/utils.ts
|
|
1855
1855
|
init_esm_shims();
|
|
1856
|
+
function calcMaxMemberCount(lengths) {
|
|
1857
|
+
return lengths.reduce((prev, curr) => prev * curr);
|
|
1858
|
+
}
|
|
1856
1859
|
function pickDefaultDrilldowns(dimensions) {
|
|
1857
1860
|
const levels = [];
|
|
1858
1861
|
const findDefaultHierarchy = (dim) => dim.hierarchies.find((h) => h.name === dim.default_hierarchy) || dim.hierarchies[0];
|
|
@@ -1860,9 +1863,20 @@ function pickDefaultDrilldowns(dimensions) {
|
|
|
1860
1863
|
if (dimension.type === "time" || levels.length < 4) {
|
|
1861
1864
|
const hierarchy = findDefaultHierarchy(dimension);
|
|
1862
1865
|
const levelIndex = dimension.type === "geo" ? hierarchy.levels.length - 1 : 0;
|
|
1863
|
-
levels.push(hierarchy.levels[levelIndex]);
|
|
1866
|
+
levels.push({ ...hierarchy.levels[levelIndex], type: dimension.type });
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
let totalCount = calcMaxMemberCount(levels.map((l) => l.count));
|
|
1870
|
+
while (totalCount > 5e6) {
|
|
1871
|
+
const geoIndex = levels.findIndex((level) => level.type === "geo");
|
|
1872
|
+
if (geoIndex !== -1) {
|
|
1873
|
+
levels.splice(geoIndex, 1);
|
|
1874
|
+
} else {
|
|
1875
|
+
levels.pop();
|
|
1864
1876
|
}
|
|
1877
|
+
totalCount = calcMaxMemberCount(levels.map((l) => l.count));
|
|
1865
1878
|
}
|
|
1879
|
+
console.log(levels, "lkvs");
|
|
1866
1880
|
return levels;
|
|
1867
1881
|
}
|
|
1868
1882
|
|