I am trying to add some fields to create date groupings, but I am getting a type error.
let dateGroups: {
area: string;
dataField: string;
dataType: string;
groupInterval: string;
}[]
Argument of type '{ area: string; dataField: string; dataType: string; groupInterval: string; }' is not assignable to parameter of type 'PivotGridDataSourceField'.
Types of property 'area' are incompatible.
Type 'string' is not assignable to type '"column" | "data" | "filter" | "row" | undefined'.ts(2345)
And here is my code:
let dateRollupFields = this.pibotGridSource.fields();
const createdAtIndex = dateRollupFields.map(o => o.caption).indexOf("Created At");
let dateGroups = [{
area: 'column',
dataField: 'created_at_date',
dataType: 'date',
groupInterval: 'month'
}, {
area: 'column',
dataField: 'created_at_date',
dataType: 'date',
groupInterval: 'year'
}]
dateRollupFields.splice(createdAtIndex + 1, 0, dateGroups[0]);
Annotate
dateGroups
as an array ofPivotGridDataSourceField
.You should be able to import the type from pivot-grid.