@univerjs-pro/engine-pivot v0.5.0-beta.1 • Docs
Class: PivotTable
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
Parameters
Parameter | Type |
---|---|
dataFieldsCollection | FieldsCollection |
model ? | PivotModel |
Returns
Defined in
pivot/pivot-table.ts:28
Properties
Property | Type | Defined in |
---|---|---|
_bufferModel | PivotModel | pivot/pivot-table.ts:25 |
dataFieldsCollection | FieldsCollection | pivot/pivot-table.ts:22 |
Methods
_generateModel()
_generateModel(): void
Returns
void
Defined in
pivot/pivot-table.ts:66
addField()
addField(
field,
area,
index?): void
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);
Defined in
pivot/pivot-table.ts:395
addFieldWithSourceId()
addFieldWithSourceId(
dataFieldId,
area,
index?): undefined | PivotTableValueField | PivotTableLabelField
- 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
Defined in
pivot/pivot-table.ts:271
createLabelFieldByDataFieldId()
createLabelFieldByDataFieldId(dataFieldId, tableName?): undefined | PivotTableLabelField
Parameters
Parameter | Type |
---|---|
dataFieldId | string |
tableName ? | string |
Returns
undefined
| PivotTableLabelField
Defined in
pivot/pivot-table.ts:70
createValueFieldByDataFieldId()
createValueFieldByDataFieldId(dataFieldId): undefined | PivotTableValueField
Parameters
Parameter | Type |
---|---|
dataFieldId | string |
Returns
undefined
| PivotTableValueField
Defined in
pivot/pivot-table.ts:82
dispose()
dispose(): void
Returns
void
Defined in
pivot/pivot-table.ts:512
endCollectChangeset()
endCollectChangeset(): IPivotTableChangeSet[]
Returns
Defined in
pivot/pivot-table.ts:53
fromJSON()
fromJSON(data): void
Parameters
Parameter | Type |
---|---|
data | IPivotTableSnapshot |
Returns
void
Defined in
pivot/pivot-table.ts:508
getDataFieldByDataFieldId()
getDataFieldByDataFieldId(dataFieldId): undefined | DataField
- 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
Defined in
pivot/pivot-table.ts:241
getDataFieldByTableId()
getDataFieldByTableId(tableField): undefined | DataField
- 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
Defined in
pivot/pivot-table.ts:187
getDataFieldItemInfo()
getDataFieldItemInfo(dataField): {
items: string[];
itemTypes: PivotDataFieldDataTypeEnum[];
}
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 |
Defined in
pivot/pivot-table.ts:245
getFieldCountByArea()
getFieldCountByArea(area): number
- get how many fields in the area
Parameters
Parameter | Type | Description |
---|---|---|
area | PivotTableFiledAreaEnum | the area of the field enum |
Returns
number
the field count
Defined in
pivot/pivot-table.ts:157
getFieldFormat()
getFieldFormat(fieldId): undefined | string
- 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.
Defined in
pivot/pivot-table.ts:372
getFieldPositionInfoById()
getFieldPositionInfoById(fieldId): {
area: undefined | PivotTableFiledAreaEnum;
index: number;
}
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.
Defined in
pivot/pivot-table.ts:431
getFilterFieldIdByIndex()
getFilterFieldIdByIndex(index): undefined | string
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
Defined in
pivot/pivot-table.ts:352
getFilterInfo()
getFilterInfo(fieldId): undefined | IPivotTableFilterInfo
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
undefined
| IPivotTableFilterInfo
Defined in
pivot/pivot-table.ts:343
getIndexesByPathStr()
getIndexesByPathStr(tuple): number[]
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
Defined in
pivot/pivot-table.ts:454
getNeedQuery()
getNeedQuery(viewVersion): boolean
- get the pivot view need query or not
Parameters
Parameter | Type |
---|---|
viewVersion | number |
Returns
boolean
- need query or not
Defined in
pivot/pivot-table.ts:422
getOptions()
getOptions(): IPivotTableOptions
Returns
Defined in
pivot/pivot-table.ts:403
getSortInfo()
getSortInfo(fieldId): undefined | IPivotTableSortInfo
- 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.
Defined in
pivot/pivot-table.ts:339
getTableFieldById()
getTableFieldById(tableFieldId): undefined | PivotTableValueField | PivotTableLabelField
- 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
Defined in
pivot/pivot-table.ts:215
getTableFieldsByDataFieldId()
getTableFieldsByDataFieldId(dataFieldId): (PivotTableValueField | PivotTableLabelField)[]
- get all the table fields by use the data field id
Parameters
Parameter | Type |
---|---|
dataFieldId | string |
Returns
(PivotTableValueField
| PivotTableLabelField
)[]
the table field ids
Defined in
pivot/pivot-table.ts:200
getUniqueFieldId()
getUniqueFieldId(): string
Returns
string
Defined in
pivot/pivot-table.ts:252
getUniqueValueFieldName()
getUniqueValueFieldName(autoName): string
- 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
Defined in
pivot/pivot-table.ts:170
getValueFields()
getValueFields(): string[]
Returns
string
[]
Defined in
pivot/pivot-table.ts:161
getValueIndex()
getValueIndex(): number
get the order index of ΣValue in row or col
Returns
number
-1 means not exist, otherwise the index of the ΣValue
Defined in
pivot/pivot-table.ts:115
getValuePosition()
getValuePosition(): PivotTableValuePositionEnum
- get the value position
Returns
the value position, only row or column
Defined in
pivot/pivot-table.ts:123
isColMultiMeasure()
isColMultiMeasure(): boolean
Returns
boolean
Defined in
pivot/pivot-table.ts:103
isEmpty()
isEmpty(): boolean
- get the pivot table is empty or not
Returns
boolean
empty or not
Defined in
pivot/pivot-table.ts:232
isExistField()
isExistField(tableFieldId): boolean
- 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
Defined in
pivot/pivot-table.ts:224
isRowMultiMeasure()
isRowMultiMeasure(): boolean
Returns
boolean
Defined in
pivot/pivot-table.ts:107
iterateField()
iterateField(callback): void
- iterate all pivot table fields
Parameters
Parameter | Type | Description |
---|---|---|
callback | (field ) => void | the callback function |
Returns
void
Defined in
pivot/pivot-table.ts:131
iterateFieldByArea()
iterateFieldByArea(area, callback): void
- 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
Defined in
pivot/pivot-table.ts:148
iterateFieldDim()
iterateFieldDim(callback): void
- iterate the dimension field, it means all the label fields
Parameters
Parameter | Type | Description |
---|---|---|
callback | (field ) => void | the callback function |
Returns
void
Defined in
pivot/pivot-table.ts:139
query()
query(config?): PivotView
Parameters
Parameter | Type |
---|---|
config ? | IPivotTableQueryData |
Returns
Defined in
pivot/pivot-table.ts:486
removeField()
removeField(fieldId): void
Parameters
Parameter | Type |
---|---|
fieldId | string |
Returns
void
Defined in
pivot/pivot-table.ts:399
renameField()
renameField(fieldId, displayName): void
- Rename the field.
Parameters
Parameter | Type | Description |
---|---|---|
fieldId | string | The id of the field. |
displayName | string | The display name of the field. |
Returns
void
Defined in
pivot/pivot-table.ts:312
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/pivot-table.ts:413
setDirty()
setDirty(dirty): void
Parameters
Parameter | Type |
---|---|
dirty | boolean |
Returns
void
Defined in
pivot/pivot-table.ts:482
setFieldFormat()
setFieldFormat(fieldId, format): void
- 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.
Defined in
pivot/pivot-table.ts:382
setFilterInfo()
setFilterInfo(fieldId, filterInfo): void
- 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
Defined in
pivot/pivot-table.ts:321
setOptions()
setOptions(options): void
Parameters
Parameter | Type |
---|---|
options | IPivotTableOptions |
Returns
void
Defined in
pivot/pivot-table.ts:284
setSortInfo()
setSortInfo(fieldId, sortInfo): void
- 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
Defined in
pivot/pivot-table.ts:330
setSubtotalType()
setSubtotalType(fieldId, subtotalType): void
- 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
Defined in
pivot/pivot-table.ts:303
startCollectChangeset()
startCollectChangeset(): void
Returns
void
Defined in
pivot/pivot-table.ts:48
toJSON()
toJSON(): IPivotTableSnapshot
Returns
Defined in
pivot/pivot-table.ts:504
updateDataFieldsCollection()
updateDataFieldsCollection(dataFieldsCollection): void
Parameters
Parameter | Type |
---|---|
dataFieldsCollection | FieldsCollection |
Returns
void
Defined in
pivot/pivot-table.ts:37
updateFieldPosition()
updateFieldPosition(
fieldId,
area,
index): void
- 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
Defined in
pivot/pivot-table.ts:362
updateFieldSourceInfo()
updateFieldSourceInfo(
fieldId,
sourceName,
dataFieldId): void
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
Defined in
pivot/pivot-table.ts:294
updateValuePosition()
updateValuePosition(valuePosition, valueIndex): void
Parameters
Parameter | Type |
---|---|
valuePosition | PivotTableValuePositionEnum |
valueIndex | number |
Returns
void
Defined in
pivot/pivot-table.ts:99