Skip to content

Commit 1450a1d

Browse files
MKirovaMKirova
authored andcommitted
Show aggregate label in chip as well.
1 parent c4c8d91 commit 1450a1d

File tree

8 files changed

+47
-35
lines changed

8 files changed

+47
-35
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid-aggregate.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class IgxPivotAggregate {
1414
public static aggregators() {
1515
return [{
1616
key: 'count',
17-
label: 'Count',
17+
label: 'COUNT',
1818
aggregator: IgxPivotAggregate.count
1919
}];
2020
}
@@ -47,24 +47,24 @@ export class IgxPivotNumericAggregate extends IgxPivotAggregate {
4747
result = result.concat(super.aggregators());
4848
result.push({
4949
key: 'min',
50-
label: 'Min',
50+
label: 'MIN',
5151
aggregator: IgxPivotNumericAggregate.min
5252
});
5353
result.push({
5454
key: 'max',
55-
label: 'Max',
55+
label: 'MAX',
5656
aggregator: IgxPivotNumericAggregate.max
5757
});
5858

5959
result.push({
6060
key: 'sum',
61-
label: 'Sum',
61+
label: 'SUM',
6262
aggregator: IgxPivotNumericAggregate.sum
6363
});
6464

6565
result.push({
6666
key: 'average',
67-
label: 'Avg',
67+
label: 'AVG',
6868
aggregator: IgxPivotNumericAggregate.average
6969
});
7070
return result;
@@ -137,12 +137,12 @@ export class IgxPivotDateAggregate extends IgxPivotAggregate {
137137
result = result.concat(super.aggregators());
138138
result.push({
139139
key: 'latest',
140-
label: 'Latest',
140+
label: 'LATEST',
141141
aggregator: IgxPivotDateAggregate.latest
142142
});
143143
result.push({
144144
key: 'earliest',
145-
label: 'Earliest',
145+
label: 'EARLIEST',
146146
aggregator: IgxPivotDateAggregate.earliest
147147
});
148148
return result;
@@ -188,12 +188,12 @@ export class IgxPivotTimeAggregate extends IgxPivotAggregate {
188188
result = result.concat(super.aggregators());
189189
result.push({
190190
key: 'latestTime',
191-
label: 'Latest Time',
191+
label: 'LATEST',
192192
aggregator: IgxPivotTimeAggregate.latestTime
193193
});
194194
result.push({
195195
key: 'earliestTime',
196-
label: 'Earliest Time',
196+
label: 'EARLIEST',
197197
aggregator: IgxPivotTimeAggregate.earliestTime
198198
});
199199
return result;

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface IPivotValue {
4343
* Aggregation function - can be a custom implementation of PivotAggregation or
4444
* use predefined ones from IgxPivotAggregate and its variants
4545
*/
46-
aggregate: PivotAggregation;
46+
aggregate: IPivotAggregator;
4747
/**
4848
* List of aggregates to show in aggregate drop-down.
4949
*/

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<igx-icon>functions</igx-icon>
6161
<igx-icon>arrow_drop_down</igx-icon>
6262
</div>
63-
{{value.displayName || value.member}}
63+
{{value.aggregate.label}}({{value.displayName || value.member}})
6464
</igx-chip>
6565
</igx-chips-area>
6666
</div>

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,16 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
7878
return val.aggregateList;
7979
}
8080
let defaultAggr = this.getAggregatorsForValue(val);
81-
const isDefault = defaultAggr.find(x => x.aggregator.name === val.aggregate.name);
81+
const isDefault = defaultAggr.find(x => x.aggregator.name === val.aggregate.key);
8282
// resolve custom aggregations
83-
if(!isDefault && this.grid.data[0][val.member] !== undefined) {
83+
if (!isDefault && this.grid.data[0][val.member] !== undefined) {
8484
// if field exists, then we can apply default aggregations and add the custom one.
85-
defaultAggr.unshift({
86-
key: 'custom',
87-
label: 'Custom',
88-
aggregator: val.aggregate
89-
});
90-
} else if(!isDefault) {
85+
defaultAggr.unshift(val.aggregate);
86+
} else if (!isDefault) {
9187
// otherwise this is a custom aggregation that is not compatible
9288
// with the defaults, since it operates on field that is not in the data
9389
// leave only the custom one.
94-
defaultAggr = [{
95-
key: 'custom',
96-
label: val.displayName || 'Custom',
97-
aggregator: val.aggregate
98-
}];
90+
defaultAggr = [val.aggregate];
9991
}
10092
return defaultAggr;
10193
}
@@ -140,13 +132,13 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
140132

141133
public onAggregationChange(event: ISelectionEventArgs) {
142134
if (!this.isSelected(event.newSelection.value)) {
143-
this.value.aggregate = event.newSelection.value.aggregator;
135+
this.value.aggregate = event.newSelection.value;
144136
this.grid.pipeTrigger++;
145137
}
146138
}
147139

148140
public isSelected(val: IPivotAggregator) {
149-
return this.value.aggregate === val.aggregator;
141+
return this.value.aggregate.key === val.key;
150142
}
151143

152144
public onDimDragOver(event, dimension?: PivotDimensionType) {

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export class PivotUtil {
195195
public static aggregate(records, values: IPivotValue[]) {
196196
const result = {};
197197
for (const pivotValue of values) {
198-
result[pivotValue.member] = pivotValue.aggregate(records.map(r => r[pivotValue.member]), records);
198+
result[pivotValue.member] = pivotValue.aggregate.aggregator(records.map(r => r[pivotValue.member]), records);
199199
}
200200

201201
return result;

src/app/pivot-grid-hierarchy/pivot-grid-hierarchy.sample.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,20 @@ export class PivotGridHierarchySampleComponent {
4747
values: [
4848
{
4949
member: 'NumberOfUnits',
50-
aggregate: IgxNumberSummaryOperand.sum,
50+
aggregate: {
51+
aggregator: IgxNumberSummaryOperand.sum,
52+
key: 'sum',
53+
label: 'Sum'
54+
},
5155
enabled: true
5256

5357
}, {
5458
member: 'Value',
55-
aggregate: IgxNumberSummaryOperand.sum,
59+
aggregate: {
60+
aggregator: IgxNumberSummaryOperand.sum,
61+
key: 'sum',
62+
label: 'Sum'
63+
},
5664
enabled: true,
5765
formatter: (val) => val ? parseFloat(val).toFixed(2) : undefined
5866
}

src/app/pivot-grid-noop/pivot-grid-noop.sample.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ export class PivotGridNoopSampleComponent {
5454
values: [
5555
{
5656
member: 'UnitsSold',
57-
aggregate: IgxNumberSummaryOperand.sum,
57+
aggregate: {
58+
aggregator: IgxNumberSummaryOperand.sum,
59+
key: 'sum',
60+
label: 'Sum'
61+
},
5862
enabled: true
5963
},
6064
],

src/app/pivot-grid/pivot-grid.sample.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export class PivotGridSampleComponent {
8282
values: [
8383
{
8484
member: 'UnitsSold',
85-
aggregate: IgxPivotNumericAggregate.sum,
85+
aggregate: {
86+
key: 'sum',
87+
aggregator: IgxPivotNumericAggregate.sum,
88+
label: 'SUM'
89+
},
8690
enabled: true,
8791
styles: {
8892
upFont: (rowData: any, columnKey: any): boolean => rowData[columnKey] > 300,
@@ -94,19 +98,23 @@ export class PivotGridSampleComponent {
9498
{
9599
member: 'AmountOfSale',
96100
displayName: 'Amount of Sale',
97-
aggregate: IgxTotalSaleAggregate.totalSale,
101+
aggregate: {
102+
key: 'sum',
103+
aggregator: IgxTotalSaleAggregate.totalSale,
104+
label: 'SUM Sale'
105+
},
98106
aggregateList: [{
99107
key: 'sum',
100108
aggregator: IgxTotalSaleAggregate.totalSale,
101-
label: 'Sum Sale'
109+
label: 'SUM Sale'
102110
},{
103111
key: 'min',
104112
aggregator: IgxTotalSaleAggregate.totalMin,
105-
label: 'Min Sale'
113+
label: 'MIN Sale'
106114
},{
107115
key: 'max',
108116
aggregator: IgxTotalSaleAggregate.totalMax,
109-
label: 'Max Sale'
117+
label: 'MAX Sale'
110118
}],
111119
enabled: true,
112120
dataType: 'currency',

0 commit comments

Comments
 (0)