@univerjs-pro/engine-pivot v0.5.4
Class: PivotTable
Defined in: pivot/pivot-table.ts:21
PivotTable - represents the wrapper class pivot table.
Description
The pivot table is a wrapper class which references the data fields collection and pivot table model.
Implements
IPivotTable
Constructors
new PivotTable()
new PivotTable(dataFieldsCollection, model?): PivotTable
Defined in: pivot/pivot-table.ts:28
Parameters
Parameter | Type |
---|---|
dataFieldsCollection | FieldsCollection |
model ? | PivotModel |
Returns
Properties
Property | Type | Defined in |
---|---|---|
_bufferModel | PivotModel | pivot/pivot-table.ts:25 |
dataFieldsCollection | FieldsCollection | pivot/pivot-table.ts:22 |
Methods
_generateModel()
_generateModel(): void
Defined in: pivot/pivot-table.ts:66
Returns
void
addField()
addField(
field,
area,
index?): void
Defined in: pivot/pivot-table.ts:395
Parameters
Parameter | Type |
---|---|
field | | PivotTableValueField | PivotTableLabelField |
area | PivotTableFiledAreaEnum |
index ? | number |
Returns
void
Example
const pt= new PivotTable(fieldsCollection);
var areaField = pt.addFieldWithSourceName('区域', PivotTableFiledAreaEnum.Column);
pt.addFieldWithSourceName('省份', PivotTableFiledAreaEnum.Filter);
addFieldWithSourceId()
addFieldWithSourceId(
dataFieldId,
area,
index?):
| undefined
| PivotTableValueField
| PivotTableLabelField
Defined in: pivot/pivot-table.ts:271
- add a field to the pivot table by the source name , if the field is a measure field, it will be use auto name.
Parameters
Parameter | Type | Description |
---|---|---|
dataFieldId | string | data field name |
area | PivotTableFiledAreaEnum | the area of the added field |
index ? | number | the position of the field in the area, if not set, the field will be added to the end of the area. |
Returns
| undefined
| PivotTableValueField
| PivotTableLabelField
the added field
createLabelFieldByDataFieldId()
createLabelFieldByDataFieldId(dataFieldId, tableName?): undefined | PivotTableLabelField
Defined in: pivot/pivot-table.ts:70
Parameters
Parameter | Type |
---|---|
dataFieldId | string |
tableName ? | string |
Returns
undefined
| PivotTableLabelField
createValueFieldByDataFieldId()
createValueFieldByDataFieldId(dataFieldId): undefined | PivotTableValueField
Defined in: pivot/pivot-table.ts:82
Parameters
Parameter | Type |
---|---|
dataFieldId | string |
Returns
undefined
| PivotTableValueField
dispose()
dispose(): void
Defined in: pivot/pivot-table.ts:512
Returns
void
endCollectChangeset()
endCollectChangeset(): IPivotTableChangeSet[]
Defined in: pivot/pivot-table.ts:53
Returns
fromJSON()
fromJSON(data): void
Defined in: pivot/pivot-table.ts:508
Parameters
Parameter | Type |
---|---|
data | IPivotTableSnapshot |
Returns
void
getDataFieldByDataFieldId()
getDataFieldByDataFieldId(dataFieldId): undefined | DataField
Defined in: pivot/pivot-table.ts:241
- get the data field by the data field id
Parameters
Parameter | Type | Description |
---|---|---|
dataFieldId | string | the data field id |
Returns
undefined
| DataField
the data field or undefined
getDataFieldByTableId()
getDataFieldByTableId(tableField): undefined | DataField
Defined in: pivot/pivot-table.ts:187
- get the data field by the table field id
Parameters
Parameter | Type | Description |
---|---|---|
tableField | string | the table field id |
Returns
undefined
| DataField
the data field or undefined
getDataFieldItemInfo()
getDataFieldItemInfo(dataField): {
items: string[];
itemTypes: PivotDataFieldDataTypeEnum[];
}
Defined in: pivot/pivot-table.ts:245
Parameters
Parameter | Type |
---|---|
dataField | DataField |
Returns
{
items: string[];
itemTypes: PivotDataFieldDataTypeEnum[];
}
Name | Type | Defined in |
---|---|---|
items | string [] | pivot/pivot-table.ts:245 |
itemTypes | PivotDataFieldDataTypeEnum [] | pivot/pivot-table.ts:245 |
getFieldCountByArea()
getFieldCountByArea(area): number
Defined in: pivot/pivot-table.ts:157
- get how many fields in the area
Parameters
Parameter | Type | Description |
---|---|---|
area | PivotTableFiledAreaEnum | the area of the field enum |
Returns
number
the field count
getFieldFormat()
getFieldFormat(fieldId): undefined | string
Defined in: pivot/pivot-table.ts:372
- get a format for pivot table field, which will be applied in the pivot table view. the label field will use the format to format the date value.
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | the field id |
Returns
undefined
| string
the field format code
Description
when a show data as type is selected, we should set the format for the field.
getFieldPositionInfoById()
getFieldPositionInfoById(fieldId): {
area: | undefined
| PivotTableFiledAreaEnum;
index: number;
}
Defined in: pivot/pivot-table.ts:431
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | the field id |
Returns
{
area: | undefined
| PivotTableFiledAreaEnum;
index: number;
}
- The position information of the field or undefined.
Name | Type | Defined in |
---|---|---|
area | | undefined | PivotTableFiledAreaEnum | pivot/pivot-table.ts:431 |
index | number | pivot/pivot-table.ts:431 |
Description
Get the field position information by the field id.
getFilterFieldIdByIndex()
getFilterFieldIdByIndex(index): undefined | string
Defined in: pivot/pivot-table.ts:352
get the filter information by the filter index
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the filter field. |
Returns
undefined
| string
the table field id
getFilterInfo()
getFilterInfo(fieldId):
| undefined
| IPivotTableFilterInfo
Defined in: pivot/pivot-table.ts:343
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
| undefined
| IPivotTableFilterInfo
getIndexesByPathStr()
getIndexesByPathStr(tuple): number[]
Defined in: pivot/pivot-table.ts:454
Find the tupleItem in the cache that matches the position order according to the passed array, and after obtaining the row number array marked on it, summarize and sort to get all the relevant source data rows
The key point here is that dimensionIdList
and dimensionTableIdList
are one-to-one index corresponding
Parameters
Parameter | Type |
---|---|
tuple | string [][] |
Returns
number
[]
-Sorted row numbers
getNeedQuery()
getNeedQuery(viewVersion): boolean
Defined in: pivot/pivot-table.ts:422
- get the pivot view need query or not
Parameters
Parameter | Type |
---|---|
viewVersion | number |
Returns
boolean
- need query or not
getOptions()
getOptions(): IPivotTableOptions
Defined in: pivot/pivot-table.ts:403
Returns
getSortInfo()
getSortInfo(fieldId):
| undefined
| IPivotTableSortInfo
Defined in: pivot/pivot-table.ts:339
- get the sort information of the dimension field.
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field. |
Returns
| undefined
| IPivotTableSortInfo
-The sort information of the field.
getTableFieldById()
getTableFieldById(tableFieldId):
| undefined
| PivotTableValueField
| PivotTableLabelField
Defined in: pivot/pivot-table.ts:215
- get the table field by the table field id
Parameters
Parameter | Type | Description |
---|---|---|
tableFieldId | string | the table field id |
Returns
| undefined
| PivotTableValueField
| PivotTableLabelField
the table field or undefined
getTableFieldsByDataFieldId()
getTableFieldsByDataFieldId(dataFieldId): (
| PivotTableValueField
| PivotTableLabelField)[]
Defined in: pivot/pivot-table.ts:200
- get all the table fields by use the data field id
Parameters
Parameter | Type |
---|---|
dataFieldId | string |
Returns
(
| PivotTableValueField
| PivotTableLabelField
)[]
the table field ids
getUniqueFieldId()
getUniqueFieldId(): string
Defined in: pivot/pivot-table.ts:252
Returns
string
getUniqueValueFieldName()
getUniqueValueFieldName(autoName): string
Defined in: pivot/pivot-table.ts:170
- get a unique field name in the pivot table
Parameters
Parameter | Type | Description |
---|---|---|
autoName | string | the given field name |
Returns
string
the unique field name
getValueFields()
getValueFields(): string[]
Defined in: pivot/pivot-table.ts:161
Returns
string
[]
getValueIndex()
getValueIndex(): number
Defined in: pivot/pivot-table.ts:115
get the order index of ΣValue in row or col
Returns
number
-1 means not exist, otherwise the index of the ΣValue
getValuePosition()
getValuePosition(): PivotTableValuePositionEnum
Defined in: pivot/pivot-table.ts:123
- get the value position
Returns
the value position, only row or column
isColMultiMeasure()
isColMultiMeasure(): boolean
Defined in: pivot/pivot-table.ts:103
Returns
boolean
isEmpty()
isEmpty(): boolean
Defined in: pivot/pivot-table.ts:232
- get the pivot table is empty or not
Returns
boolean
empty or not
isExistField()
isExistField(tableFieldId): boolean
Defined in: pivot/pivot-table.ts:224
- check the field is exist in the pivot table or not
Parameters
Parameter | Type | Description |
---|---|---|
tableFieldId | string | the check field id |
Returns
boolean
exist or not
isRowMultiMeasure()
isRowMultiMeasure(): boolean
Defined in: pivot/pivot-table.ts:107
Returns
boolean
iterateField()
iterateField(callback): void
Defined in: pivot/pivot-table.ts:131
- iterate all pivot table fields
Parameters
Parameter | Type | Description |
---|---|---|
callback | (field ) => void | the callback function |
Returns
void
iterateFieldByArea()
iterateFieldByArea(area, callback): void
Defined in: pivot/pivot-table.ts:148
- iterate the field by the area
Parameters
Parameter | Type | Description |
---|---|---|
area | PivotTableFiledAreaEnum | the area of the field enum |
callback | (field ) => void | the callback function |
Returns
void
iterateFieldDim()
iterateFieldDim(callback): void
Defined in: pivot/pivot-table.ts:139
- iterate the dimension field, it means all the label fields
Parameters
Parameter | Type | Description |
---|---|---|
callback | (field ) => void | the callback function |
Returns
void
query()
query(config?): PivotView
Defined in: pivot/pivot-table.ts:486
Parameters
Parameter | Type |
---|---|
config ? | IPivotTableQueryData |
Returns
removeField()
removeField(fieldId): void
Defined in: pivot/pivot-table.ts:399
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
void
renameField()
renameField(fieldId, displayName): void
Defined in: pivot/pivot-table.ts:312
- Rename the field.
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field. |
displayName | string | The display name of the field. |
Returns
void
setCollapse()
setCollapse(
fieldId,
collapse,
item?): void
Defined in: pivot/pivot-table.ts:413
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.
setDirty()
setDirty(dirty): void
Defined in: pivot/pivot-table.ts:482
Parameters
Parameter | Type |
---|---|
dirty | boolean |
Returns
void
setFieldFormat()
setFieldFormat(fieldId, format): void
Defined in: pivot/pivot-table.ts:382
- set the format for pivot table field, which will be applied in the pivot table view. the label field will use the format to format the date value.
Parameters
Parameter | Type |
---|---|
fieldId | string |
format | undefined | string |
Returns
void
Description
when a show data as type is selected, we should set the format for the field. a label field which contains the date value should set the format.
setFilterInfo()
setFilterInfo(fieldId, filterInfo): void
Defined in: pivot/pivot-table.ts:321
- Set the filter information of the dimension field. only the dimension field can set the filter information.
Parameters
Parameter | Type |
---|---|
fieldId | string |
filterInfo | IPivotTableFilterInfo |
Returns
void
setOptions()
setOptions(options): void
Defined in: pivot/pivot-table.ts:284
Parameters
Parameter | Type |
---|---|
options | IPivotTableOptions |
Returns
void
setSortInfo()
setSortInfo(fieldId, sortInfo): void
Defined in: pivot/pivot-table.ts:330
- Set the sort information of the dimension field. only the dimension field can set the sort information.
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field. |
sortInfo | | undefined | IPivotTableSortInfo | The sort information of the field. |
Returns
void
setSubtotalType()
setSubtotalType(fieldId, subtotalType): void
Defined in: pivot/pivot-table.ts:303
- Set the subtotal type of the field. only the value field can set the subtotal type. only effective for the value field.
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field. |
subtotalType | PivotSubtotalTypeEnum | The subtotal type of the field. |
Returns
void
startCollectChangeset()
startCollectChangeset(): void
Defined in: pivot/pivot-table.ts:48
Returns
void
toJSON()
toJSON(): IPivotTableSnapshot
Defined in: pivot/pivot-table.ts:504
Returns
updateDataFieldsCollection()
updateDataFieldsCollection(dataFieldsCollection): void
Defined in: pivot/pivot-table.ts:37
Parameters
Parameter | Type |
---|---|
dataFieldsCollection | FieldsCollection |
Returns
void
updateFieldPosition()
updateFieldPosition(
fieldId,
area,
index): void
Defined in: pivot/pivot-table.ts:362
- set the position of the field in the pivot table. which used in pivot panel drag field.
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the pivot table field. |
area | PivotTableFiledAreaEnum | which area the field will be placed. |
index | number | the index of the field in the area. |
Returns
void
updateFieldSourceInfo()
updateFieldSourceInfo(
fieldId,
sourceName,
dataFieldId): void
Defined in: pivot/pivot-table.ts:294
the func is only use for when refresh
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | the table field id |
sourceName | string | the source name of the field |
dataFieldId | string | the data field id |
Returns
void
updateValuePosition()
updateValuePosition(valuePosition, valueIndex): void
Defined in: pivot/pivot-table.ts:99
Parameters
Parameter | Type |
---|---|
valuePosition | PivotTableValuePositionEnum |
valueIndex | number |
Returns
void