Skip to content

Commit

Permalink
✨ (data table) hide change columns for non-numerical data
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Aug 20, 2024
1 parent 7aa5910 commit 12c14f3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/@ourworldindata/grapher/src/dataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -789,15 +789,18 @@ export class DataTable extends React.Component<{
targetTimes: number[]
targetTimeMode: TargetTimeMode
}): DimensionColumn[] {
// Inject delta columns if we have start & end values to compare in the table.
// One column for absolute difference, another for % difference.
// Inject delta columns if the data is numerical and we have start & end
// values to compare in the table. One column for absolute difference,
// another for % difference.
const deltaColumns: DimensionColumn[] = []
if (targetTimeMode === TargetTimeMode.range) {
const { tableDisplay = {} } = sourceColumn.display ?? {}
if (!tableDisplay.hideAbsoluteChange)
deltaColumns.push({ key: RangeValueKey.delta })
if (!tableDisplay.hideRelativeChange)
deltaColumns.push({ key: RangeValueKey.deltaRatio })
if (sourceColumn.hasNumberFormatting) {
if (targetTimeMode === TargetTimeMode.range) {
const { tableDisplay = {} } = sourceColumn.display ?? {}
if (!tableDisplay.hideAbsoluteChange)
deltaColumns.push({ key: RangeValueKey.delta })
if (!tableDisplay.hideRelativeChange)
deltaColumns.push({ key: RangeValueKey.deltaRatio })
}
}

const valueColumns = targetTimes.map((targetTime, index) => ({
Expand Down

0 comments on commit 12c14f3

Please sign in to comment.