Skip to content

Commit

Permalink
🐛 Address both convertion issue at the source
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed May 28, 2021
1 parent 13fb8cb commit 266dd99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ export function TableDimensionEditor(
[]
: [accessor];
const minMaxByColumnId = findMinMaxByColumnId(columnsToCheck, currentData);
const currentMinMax = minMaxByColumnId[accessor] || {
min: defaultPaletteParams.rangeMin,
max: defaultPaletteParams.rangeMax,
};
const currentMinMax = minMaxByColumnId[accessor];

const activePalette = column?.palette || {
type: 'palette',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Datatable } from 'src/plugins/expressions';
import { getOriginalId } from '../transpose_helpers';

export const findMinMaxByColumnId = (columnIds: string[], table: Datatable | undefined) => {
const minMax: Record<string, { min: number; max: number }> = {};
const minMax: Record<string, { min: number; max: number; fallback?: boolean }> = {};

if (table != null) {
for (const columnId of columnIds) {
Expand All @@ -26,6 +26,10 @@ export const findMinMaxByColumnId = (columnIds: string[], table: Datatable | und
}
}
});
// what happens when there's no data in the table? Fallback to a percent range
if (minMax[originalId].max === -Infinity) {
minMax[originalId] = { max: 100, min: 0, fallback: true };
}
}
}
return minMax;
Expand Down

0 comments on commit 266dd99

Please sign in to comment.