mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
fix(TableChart): render cell bars for columns with NULL values (#36819)
This commit is contained in:
@@ -67,11 +67,22 @@ function getValueRange(
|
||||
alignPositiveNegative: boolean,
|
||||
data: InputData[],
|
||||
) {
|
||||
if (typeof data?.[0]?.[key] === 'number') {
|
||||
const nums = data.map(row => row[key]) as number[];
|
||||
return (
|
||||
alignPositiveNegative ? [0, d3Max(nums.map(Math.abs))] : d3Extent(nums)
|
||||
) as ValueRange;
|
||||
const nums = data
|
||||
.map(row => {
|
||||
const raw = row[key];
|
||||
return raw instanceof Number ? raw.valueOf() : raw;
|
||||
})
|
||||
.filter(
|
||||
(value): value is number =>
|
||||
typeof value === 'number' && Number.isFinite(value),
|
||||
) as number[];
|
||||
if (nums.length > 0) {
|
||||
const maxAbs = d3Max(nums.map(Math.abs));
|
||||
if (alignPositiveNegative) {
|
||||
return [0, maxAbs ?? 0] as ValueRange;
|
||||
}
|
||||
const extent = d3Extent(nums) as ValueRange | undefined;
|
||||
return extent ?? [0, 0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user