Skip to content

Commit

Permalink
Merge branch 'master' into sstoychev/inner-scroll-extra-master
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronosSF authored Feb 15, 2022
2 parents d8faa29 + 06cbc5d commit 8e037fc
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class IgxPivotDateDimension implements IPivotDimension {
memberName: 'Quarters',
memberFunction: (rec) => {
const recordValue = PivotUtil.extractValueFromDimension(inBaseDimension, rec);
return recordValue ? `Q` + Math.floor((new Date(recordValue).getMonth() + 1) / 3) : rec['Quarters'];
return recordValue ? `Q` + Math.ceil((new Date(recordValue).getMonth() + 1) / 3) : rec['Quarters'];
},
enabled: true,
childLevel: monthDimension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1654,4 +1654,60 @@ describe('Pivot pipes #pivotGrid', () => {
// all values should be strings as the result of the processed member function is string.
expect(res.filter(x => typeof x !== 'string').length).toBe(0);
});

it('should generate correct values for IgxPivotDateDimension with quarters enabled.', () => {
data = [
{ Date: '01/19/2020', UnitsSold: 492 },
{ Date: '02/19/2020', UnitsSold: 200 },
{ Date: '03/19/2020', UnitsSold: 178 },
{ Date: '04/19/2020', UnitsSold: 456 },
{ Date: '05/19/2020', UnitsSold: 456 },
{ Date: '06/19/2020', UnitsSold: 0 },
{ Date: '07/19/2020', UnitsSold: 500 },
{ Date: '08/19/2020', UnitsSold: 100 },
{ Date: '09/19/2020', UnitsSold: 300 },
{ Date: '10/19/2020', UnitsSold: 100 },
{ Date: '11/19/2020', UnitsSold: 200 },
{ Date: '12/19/2020', UnitsSold: 456 }
];
pivotConfig.columns = [];
pivotConfig.rows = [
new IgxPivotDateDimension(
{
memberName: 'Date',
enabled: true
},
{
months: true,
quarters: true,
fullDate: false
}
)
]
const rowPipeResult = rowPipe.transform(data, pivotConfig, expansionStates);
const columnPipeResult = columnPipe.transform(rowPipeResult, pivotConfig, new Map<any, boolean>());
const rowStatePipeResult = rowStatePipe.transform(columnPipeResult, pivotConfig, expansionStates, true);

const dateData = PivotGridFunctions.getDimensionData(rowStatePipeResult, pivotConfig.rows);
expect(dateData).toEqual([
{ 'AllPeriods': 'All Periods' },
{ 'Years': '2020' },
{ 'Quarters': 'Q1' },
{ 'Months': 'January' },
{ 'Months': 'February' },
{ 'Months': 'March' },
{ 'Quarters': 'Q2' },
{ 'Months': 'April' },
{ 'Months': 'May' },
{ 'Months': 'June' },
{ 'Quarters': 'Q3' },
{ 'Months': 'July' },
{ 'Months': 'August' },
{ 'Months': 'September' },
{ 'Quarters': 'Q4' },
{ 'Months': 'October' },
{ 'Months': 'November' },
{ 'Months': 'December' }
]);
});
});
56 changes: 51 additions & 5 deletions src/app/pivot-grid/pivot-grid.sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export class PivotGridSampleComponent {
enabled: true
},
{
months: false
months: false,
quarters: true
}
),
{
Expand Down Expand Up @@ -194,12 +195,57 @@ export class PivotGridSampleComponent {
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '05/12/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 16.05, SellerName: 'Walter',
Country: 'Bulgaria', City: 'Plovdiv', Date: '02/19/2020', UnitsSold: 492
}];

public data2 = [{
ProductCategory: 'Clothing', UnitPrice: 16.05, SellerName: 'Walter',
Country: 'Bulgaria', City: 'Plovdiv', Date: '01/19/2020', UnitsSold: 492
},
{
ProductCategory: 'Clothing', UnitPrice: 16.05, SellerName: 'Walter',
Country: 'Bulgaria', City: 'Plovdiv', Date: '02/19/2020', UnitsSold: 492
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '03/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '04/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '05/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '06/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '07/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '08/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '09/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '10/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '11/19/2020', UnitsSold: 456
},
{
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '12/19/2020', UnitsSold: 456
}];

public handleChange(event) {
let isColumnChange = false
const allDims = this.pivotConfigHierarchy.rows.concat(this.pivotConfigHierarchy.columns).concat(this.pivotConfigHierarchy.filters);
Expand Down

0 comments on commit 8e037fc

Please sign in to comment.