Skip to content

Commit

Permalink
enhance: revert MissingDataStrategy.auto behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Aug 15, 2024
1 parent 0d16ece commit 286c2ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
14 changes: 0 additions & 14 deletions packages/@ourworldindata/core-table/src/OwidTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,6 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
)
}

dropRowsWithAtLeastThisManyErrorValuesForColumns(
slugs: ColumnSlug[],
minErrorValues: number
): this {
return this.rowFilter(
(row) =>
slugs.filter((slug) => !isNotErrorValue(row[slug])).length <
minErrorValues,
`Drop rows with at least ${minErrorValues} ErrorValues in every column: ${slugs.join(
", "
)}`
)
}

// Drop _all rows_ for an entity if there is any column that has no valid values for that entity.
dropEntitiesThatHaveNoDataInSomeColumn(columnSlugs: ColumnSlug[]): this {
const indexesByEntityName = this.rowIndicesByEntityName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,9 @@ export class StackedDiscreteBarChart
// If MissingDataStrategy is explicitly set to hide, drop rows (= times) where one of
// the y columns has no data
return table.dropRowsWithErrorValuesForAnyColumn(this.yColumnSlugs)
} else if (this.missingDataStrategy === MissingDataStrategy.auto) {
// If MissingDataStrategy is set to auto, drop rows where there is only a single non-error value
if (this.yColumnSlugs.length > 1) {
return table.dropRowsWithAtLeastThisManyErrorValuesForColumns(
this.yColumnSlugs,
this.yColumnSlugs.length - 1
)
}
}

// Otherwise, don't apply any special treatment
return table
}

Expand Down

0 comments on commit 286c2ee

Please sign in to comment.