fix(TableChart): render cell bars for columns with NULL values (#36819)

This commit is contained in:
Luis Sánchez
2025-12-31 11:51:35 -03:00
committed by GitHub
parent 85e830de46
commit c31224c891
3 changed files with 90 additions and 6 deletions

View File

@@ -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;
}