@datawheel/data-explorer 1.3.1 → 1.3.2

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 CHANGED
@@ -220,6 +220,7 @@ interface TesseractLevel {
220
220
  properties: TesseractProperty[];
221
221
  type?: "geo" | "time" | string;
222
222
  count?: number;
223
+ time_scale?: string;
223
224
  }
224
225
  interface TesseractProperty {
225
226
  name: string;
package/dist/main.mjs CHANGED
@@ -1987,12 +1987,8 @@ function pickDefaultDrilldowns(dimensions, cube) {
1987
1987
  for (const dimension of dimensions) {
1988
1988
  if (dimension.type === "time" || requiredDimensions.includes(dimension.name) || levels.length < 4) {
1989
1989
  const hierarchy = findDefaultHierarchy(dimension);
1990
- const hierarchyDepth = Math.max(...hierarchy.levels.map((l) => l.depth));
1991
1990
  const levelIndex = dimension.type === "geo" ? hierarchy.levels.length - 1 : 0;
1992
1991
  const defaultLevel = hierarchy.levels[levelIndex];
1993
- if (dimension.type === "time" && dimension.annotations.de_time_complete === "true" && defaultLevel.depth < hierarchyDepth) {
1994
- timeComplete = defaultLevel.name;
1995
- }
1996
1992
  levels.push({ ...defaultLevel, type: dimension.type });
1997
1993
  }
1998
1994
  }
@@ -2017,6 +2013,25 @@ function pickDefaultDrilldowns(dimensions, cube) {
2017
2013
  }
2018
2014
  }
2019
2015
  }
2016
+ for (const dimension of dimensions) {
2017
+ if (dimension.annotations.de_time_complete === "true") {
2018
+ const hierarchy = findDefaultHierarchy(dimension);
2019
+ const hierarchyLevels = hierarchy.levels;
2020
+ const availableLevels = hierarchyLevels.filter((hl) => levels.some((l) => l.name === hl.name));
2021
+ if (availableLevels.length > 0) {
2022
+ const timeCompleteLevel = availableLevels.reduce(
2023
+ (prev, curr) => curr.depth < prev.depth ? curr : prev
2024
+ );
2025
+ const deepestLevel = hierarchyLevels.reduce(
2026
+ (prev, curr) => curr.depth > prev.depth ? curr : prev
2027
+ );
2028
+ const deepestLevelSelected = availableLevels.some((l) => l.depth === deepestLevel.depth);
2029
+ if (timeCompleteLevel.depth < deepestLevel.depth && !deepestLevelSelected) {
2030
+ timeComplete = timeCompleteLevel.name;
2031
+ }
2032
+ }
2033
+ }
2034
+ }
2020
2035
  let totalCount = calcMaxMemberCount(levels.map((l) => l.count));
2021
2036
  while (totalCount > 5e6) {
2022
2037
  const geoIndex = levels.findIndex((level) => level.type === "geo");
@@ -3271,7 +3286,8 @@ function useTable({
3271
3286
  range,
3272
3287
  isId
3273
3288
  } = keyCol;
3274
- const isNumeric = valueType === "number" && !/Year/i.test(columnKey);
3289
+ const isYearDrilldown = entityType === "level" && entity.time_scale && /Year/i.test(columnKey);
3290
+ const isNumeric = valueType === "number" && !isYearDrilldown;
3275
3291
  const formatterKey = getFormat(
3276
3292
  "aggregator" in entity ? entity : columnKey,
3277
3293
  isNumeric ? "Decimal" : "identity"
@@ -4324,7 +4340,9 @@ function FilterItem2({
4324
4340
  onChange: () => {
4325
4341
  if (!isLastSelected) {
4326
4342
  actions2.updateMeasure({ ...measure, active: !measure.active });
4327
- actions2.updateFilter({ ...filter, active: !checked });
4343
+ if (checked) {
4344
+ actions2.updateFilter({ ...filter, active: false });
4345
+ }
4328
4346
  }
4329
4347
  },
4330
4348
  checked,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/data-explorer",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "main": "./dist/main.mjs",
5
5
  "types": "./dist/main.d.mts",
6
6
  "files": [