Skip to content

Commit

Permalink
AG-12978 Fix normalised stacked area for null (un-)connected cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lsjroberts committed Dec 4, 2024
1 parent adcd1e0 commit d2ffa32
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions packages/ag-charts-community/src/chart/data/processors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,20 @@ function normaliseFindExtent(mode: 'sum' | 'range', columns: any[][], valueIndex
for (const valueIdx of valueIndexes) {
const column = columns[valueIdx];
const value: null | number | (null | number)[] = column[datumIndex];
if (value == null) continue;
// Note - Array.isArray(new Float64Array) is false, and this type is used for stack accumulators
const valueExtent = typeof value === 'number' ? value : Math.max(...value.map((v) => v ?? 0));
const valIdx = valueExtent < 0 ? 0 : 1;
if (value == null || typeof value !== 'number') continue;
const valIdx = value < 0 ? 0 : 1;
if (mode === 'sum') {
valuesExtent[valIdx] += valueExtent;
valuesExtent[valIdx] += value;
} else if (valIdx === 0) {
valuesExtent[valIdx] = Math.min(valuesExtent[valIdx], valueExtent);
valuesExtent[valIdx] = Math.min(valuesExtent[valIdx], value);
} else {
valuesExtent[valIdx] = Math.max(valuesExtent[valIdx], valueExtent);
valuesExtent[valIdx] = Math.max(valuesExtent[valIdx], value);
}
}

return Math.max(Math.abs(valuesExtent[0]), valuesExtent[1]);
const extent = Math.max(Math.abs(valuesExtent[0]), valuesExtent[1]);
if (extent === 0) return NaN;
return extent;
}

export function normaliseGroupTo(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class AreaSeries extends CartesianSeries<
}

const common: Partial<DatumPropertyDefinition<unknown>> = { invalidValue: null };
if ((isDefined(normalizedTo) || connectMissingData) && stackCount > 1) {
if (connectMissingData && stackCount > 1) {
common.invalidValue = 0;
}
if (!visible) {
Expand Down

0 comments on commit d2ffa32

Please sign in to comment.