@univerjs-pro/engine-pivot v0.5.0-beta.1 • Docs
Class: PivotModel
PivotModel represents a config model for a pivot table.
Description
The pivot model is a class that stores the pivot table’s configuration information.
Constructors
new PivotModel()
new PivotModel(): PivotModel
Returns
Defined in
pivot/model.ts:91
Properties
Property | Type | Default value | Description | Defined in |
---|---|---|---|---|
_changeStack | IPivotTableChangeSet [] | undefined | - | pivot/model.ts:84 |
collapseInfo | Record <string , boolean | Record <string , boolean >> | {} | The collapse information of the pivot table. Which data structure is {fieldId: boolean | {item: boolean}} |
columnFields | string [] | [] | An array of column fields id. | pivot/model.ts:32 |
dimension | Record <string , PivotTableLabelField > | {} | A object of dimension fields, which key is the field id and value is the field. | pivot/model.ts:52 |
filterFields | string [] | [] | An array of filter fields id. | pivot/model.ts:42 |
hiddenFields | string [] | [] | An array of hidden fields id. | pivot/model.ts:47 |
layout | PivotLayoutTypeEnum | PivotLayoutTypeEnum.tabular | The layout type of the pivot table. | pivot/model.ts:73 |
measure | Record <string , PivotTableValueField > | {} | A object of measure fields, which key is the field id and value is the field. | pivot/model.ts:57 |
options | IPivotTableOptions | undefined | Creates an instance of PivotModel. | pivot/model.ts:82 |
rowFields | string [] | [] | An array of row fields id. | pivot/model.ts:27 |
valueFields | string [] | [] | An array of value fields id. | pivot/model.ts:37 |
valueIndex | number | -1 | The special ΣValue fields order index in the dimension fields | pivot/model.ts:63 |
valuePosition | PivotTableValuePositionEnum | PivotTableValuePositionEnum.None | The special ΣValue fields position in row or column area. | pivot/model.ts:68 |
Methods
addField()
addField(
field,
area,
index?): void
Parameters
Parameter | Type | Description |
---|---|---|
field | PivotTableValueField | PivotTableLabelField | the field to be added. |
area | PivotTableFiledAreaEnum | The area to add the field. |
index ? | number | The index of the field in the area. |
Returns
void
Description
Add a field to the pivot table.
Defined in
pivot/model.ts:270
cloneBufferModel()
cloneBufferModel(): PivotModel
Returns
Defined in
pivot/model.ts:694
endChangeStack()
endChangeStack(): IPivotTableChangeSet[]
Returns
Defined in
pivot/model.ts:103
fromJSON()
fromJSON(data): void
Parameters
Parameter | Type |
---|---|
data | IPivotTableSnapshot |
Returns
void
Defined in
pivot/model.ts:638
getDirty()
getDirty(): boolean
- get the dirty status of the pivot table.
Returns
boolean
- The dirty status of the pivot table.
Defined in
pivot/model.ts:122
getFieldById()
getFieldById(fieldId): undefined | PivotTableValueField | PivotTableLabelField
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
undefined
| PivotTableValueField
| PivotTableLabelField
Defined in
pivot/model.ts:380
getFieldFormat()
getFieldFormat(fieldId): undefined | string
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
undefined
| string
Defined in
pivot/model.ts:180
getFieldPositionInfoById()
getFieldPositionInfoById(fieldId): {
area: undefined | PivotTableFiledAreaEnum;
index: number;
}
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field. |
Returns
{
area: undefined | PivotTableFiledAreaEnum;
index: number;
}
PositionInfo - The position info of the field. if the field is not in the pivot table, the area will be undefined and the index will be -1.
Name | Type | Defined in |
---|---|---|
area | undefined | PivotTableFiledAreaEnum | pivot/model.ts:321 |
index | number | pivot/model.ts:321 |
Description
Get where the field bo be position info by field id.
Defined in
pivot/model.ts:321
getFieldsAreaByType()
getFieldsAreaByType(type): string[]
Parameters
Parameter | Type |
---|---|
type | PivotTableFiledAreaEnum |
Returns
string
[]
Defined in
pivot/model.ts:365
getFilterInfo()
getFilterInfo(fieldId): undefined | IPivotTableFilterInfo
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
undefined
| IPivotTableFilterInfo
Defined in
pivot/model.ts:226
getOptions()
getOptions(): IPivotTableOptions
- Get the options of the pivot table. It is a copy of the options.
Returns
- The options of the pivot table.
Defined in
pivot/model.ts:145
getQueryData()
getQueryData(): IPivotTableQueryData
Represents the query data of the pivot table.Which is used to query the data from the data collection.
Returns
- The query data of the pivot table.
Defined in
pivot/model.ts:599
getSortInfo()
getSortInfo(fieldId): undefined | IPivotTableSortInfo
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
undefined
| IPivotTableSortInfo
Defined in
pivot/model.ts:219
getValueIndex()
getValueIndex(): number
- The special ΣValue fields order index in the dimension fields
Returns
number
the index
Defined in
pivot/model.ts:537
getValuePosition()
getValuePosition(): PivotTableValuePositionEnum
Returns
Defined in
pivot/model.ts:541
isColMultiMeasure()
isColMultiMeasure(): boolean
- Whether the pivot table has the special ΣValue fields in column area.
Returns
boolean
- has or not.
Defined in
pivot/model.ts:549
isEmpty()
isEmpty(): boolean
Returns
boolean
Defined in
pivot/model.ts:573
isExistFieldName()
isExistFieldName(fieldName): boolean
Parameters
Parameter | Type |
---|---|
fieldName | string |
Returns
boolean
Defined in
pivot/model.ts:390
isRowMultiMeasure()
isRowMultiMeasure(): boolean
- Whether the pivot table has the special ΣValue fields in row area.
Returns
boolean
- has or not.
Defined in
pivot/model.ts:566
iterateField()
iterateField(callback): void
Parameters
Parameter | Type |
---|---|
callback | (field ) => void |
Returns
void
Defined in
pivot/model.ts:233
iterateFieldByArea()
iterateFieldByArea(area, callback): void
Parameters
Parameter | Type |
---|---|
area | PivotTableFiledAreaEnum |
callback | (field ) => void |
Returns
void
Defined in
pivot/model.ts:254
iterateFieldDim()
iterateFieldDim(callback): void
Parameters
Parameter | Type |
---|---|
callback | (field ) => void |
Returns
void
Defined in
pivot/model.ts:242
iterateFieldMeasure()
iterateFieldMeasure(callback): void
Parameters
Parameter | Type |
---|---|
callback | (field ) => void |
Returns
void
Defined in
pivot/model.ts:248
removeField()
removeField(fieldId): void
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field to be removed. |
Returns
void
-void
Description
Remove a field from the pivot table by the field id.
Defined in
pivot/model.ts:441
renameField()
renameField(fieldId, displayName): void
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field to be renamed. |
displayName | string | The new display name of the field. |
Returns
void
Description
Rename a field in the pivot table.
Defined in
pivot/model.ts:410
setCollapse()
setCollapse(
fieldId,
collapse,
item?): void
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field. |
collapse | boolean | The collapse status of the field. |
item ? | string | The item of the field. |
Returns
void
Description
Set the collapse status of the field. Those properties are used to save the collapse status of the field in the pivot table.
Defined in
pivot/model.ts:155
setDirty()
setDirty(dirty): void
- set a dirty status to flag the pivot table whether it is changed.
Parameters
Parameter | Type |
---|---|
dirty | boolean |
Returns
void
Defined in
pivot/model.ts:114
setFieldFormat()
setFieldFormat(fieldId, format): void
Parameters
Parameter | Type |
---|---|
fieldId | string |
format | undefined | string |
Returns
void
Defined in
pivot/model.ts:190
setFilterInfo()
setFilterInfo(fieldId, filterInfo): void
Parameters
Parameter | Type |
---|---|
fieldId | string |
filterInfo | IPivotTableFilterInfo |
Returns
void
Defined in
pivot/model.ts:168
setOptions()
setOptions(options): void
- Set the options of the pivot table.
Parameters
Parameter | Type | Description |
---|---|---|
options | IPivotTableOptions | The options to be set. |
Returns
void
Defined in
pivot/model.ts:131
setSortInfo()
setSortInfo(fieldId, sortInfo): void
Parameters
Parameter | Type |
---|---|
fieldId | string |
sortInfo | undefined | IPivotTableSortInfo |
Returns
void
Defined in
pivot/model.ts:206
setSubtotalType()
setSubtotalType(tableFieldId, subtotal): void
- set or update a field’s subtotal type. , the table field must in the value area.
Parameters
Parameter | Type | Description |
---|---|---|
tableFieldId | string | The id of the pivot table field. |
subtotal | PivotSubtotalTypeEnum | The subtotal type. |
Returns
void
Defined in
pivot/model.ts:582
startChangeStack()
startChangeStack(): void
Returns
void
Defined in
pivot/model.ts:99
toJSON()
toJSON(): IPivotTableSnapshot
Returns
Defined in
pivot/model.ts:667
updateFieldPosition()
updateFieldPosition(
fieldId,
area,
index): void
Parameters
Parameter | Type |
---|---|
fieldId | string |
area | PivotTableFiledAreaEnum |
index | number |
Returns
void
Defined in
pivot/model.ts:465
updateFieldSourceInfo()
updateFieldSourceInfo(
fieldId,
sourceName,
dataFieldId): void
Parameters
Parameter | Type |
---|---|
fieldId | string |
sourceName | string |
dataFieldId | string |
Returns
void
Defined in
pivot/model.ts:343
updateValuePosition()
updateValuePosition(valuePosition, valueIndex): void
- Update the value position of the pivot table.
Parameters
Parameter | Type |
---|---|
valuePosition | PivotTableValuePositionEnum |
valueIndex | number |
Returns
void
Defined in
pivot/model.ts:522