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 a2fccf0
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/ag-charts-community/src/chart/data/processors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,19 @@ function normaliseFnBuilder({ normaliseTo, mode }: { normaliseTo: number; mode:
}

function normaliseFindExtent(mode: 'sum' | 'range', columns: any[][], valueIndexes: number[], datumIndex: number) {
let everyValueIsNaN = true;
const valuesExtent = [0, 0];
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));

if (isNaN(valueExtent)) continue;
everyValueIsNaN = false;

const valIdx = valueExtent < 0 ? 0 : 1;
if (mode === 'sum') {
valuesExtent[valIdx] += valueExtent;
Expand All @@ -228,7 +234,10 @@ function normaliseFindExtent(mode: 'sum' | 'range', columns: any[][], valueIndex
}
}

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

if (everyValueIsNaN || 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.
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 a2fccf0

Please sign in to comment.