Skip to content

Commit

Permalink
feat: support calculate field for PivotTable #1941
Browse files Browse the repository at this point in the history
  • Loading branch information
fangsmile committed Jun 19, 2024
1 parent 1df75f4 commit 326e215
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/vtable/src/dataset/statistics-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export abstract class Aggregator implements IAggregator {
formatFun?: any;
_formatedValue?: any;

constructor(key: string, dimension: string, formatFun?: any, isRecord?: boolean) {
this.key = key;
this.field = dimension;
this.formatFun = formatFun;
this.isRecord = isRecord ?? this.isRecord;
constructor(config: { key: string; dimension: string; formatFun?: any; isRecord?: boolean }) {
this.key = config.key;
this.field = config.dimension;
this.formatFun = config.formatFun;
this.isRecord = config.isRecord ?? this.isRecord;
}
abstract push(record: any): void;
abstract value(): any;
Expand Down Expand Up @@ -112,7 +112,7 @@ export class CustomAggregator extends Aggregator {
isRecord?: boolean;
aggregationFun?: Function;
}) {
super(config.key, config.dimension, config.formatFun, config.isRecord);
super(config);
this.aggregationFun = config.aggregationFun;
}
push(record: any): void {
Expand Down Expand Up @@ -160,7 +160,7 @@ export class RecalculateAggregator extends Aggregator {
dependAggregators: Aggregator[];
dependIndicatorKeys: string[];
}) {
super(config.key, config.dimension, config.formatFun, config.isRecord);
super(config);
this.calculateFun = config.calculateFun;
this.dependAggregators = config.dependAggregators;
this.dependIndicatorKeys = config.dependIndicatorKeys;
Expand Down Expand Up @@ -203,7 +203,7 @@ export class SumAggregator extends Aggregator {
isRecord?: boolean;
needSplitPositiveAndNegative?: boolean;
}) {
super(config.key, config.dimension, config.formatFun, config.isRecord);
super(config);
this.needSplitPositiveAndNegativeForSum = config.needSplitPositiveAndNegative ?? false;
}
push(record: any): void {
Expand Down

0 comments on commit 326e215

Please sign in to comment.