@univerjs-pro/engine-pivot v0.5.4


Class: PivotModel

Defined in: pivot/model.ts:23

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

Defined in: pivot/model.ts:91

Returns

PivotModel

Properties

PropertyTypeDefault valueDescriptionDefined in
_changeStackIPivotTableChangeSet[]undefined-pivot/model.ts:84
collapseInfoRecord<string, boolean | Record<string, boolean>>{}The collapse information of the pivot table. Which data structure is {fieldId: boolean{item: boolean}}
columnFieldsstring[][]An array of column fields id.pivot/model.ts:32
dimensionRecord<string, PivotTableLabelField>{}A object of dimension fields, which key is the field id and value is the field.pivot/model.ts:52
filterFieldsstring[][]An array of filter fields id.pivot/model.ts:42
hiddenFieldsstring[][]An array of hidden fields id.pivot/model.ts:47
layoutPivotLayoutTypeEnumPivotLayoutTypeEnum.tabularThe layout type of the pivot table.pivot/model.ts:73
measureRecord<string, PivotTableValueField>{}A object of measure fields, which key is the field id and value is the field.pivot/model.ts:57
optionsIPivotTableOptionsundefinedCreates an instance of PivotModel.pivot/model.ts:82
rowFieldsstring[][]An array of row fields id.pivot/model.ts:27
valueFieldsstring[][]An array of value fields id.pivot/model.ts:37
valueIndexnumber-1The special ΣValue fields order index in the dimension fieldspivot/model.ts:63
valuePositionPivotTableValuePositionEnumPivotTableValuePositionEnum.NoneThe special ΣValue fields position in row or column area.pivot/model.ts:68

Methods

addField()

addField(
   field, 
   area, 
   index?): void

Defined in: pivot/model.ts:270

Parameters

ParameterTypeDescription
field| PivotTableValueField | PivotTableLabelFieldthe field to be added.
areaPivotTableFiledAreaEnumThe area to add the field.
index?numberThe index of the field in the area.

Returns

void

Description

Add a field to the pivot table.


cloneBufferModel()

cloneBufferModel(): PivotModel

Defined in: pivot/model.ts:694

Returns

PivotModel


endChangeStack()

endChangeStack(): IPivotTableChangeSet[]

Defined in: pivot/model.ts:103

Returns

IPivotTableChangeSet[]


fromJSON()

fromJSON(data): void

Defined in: pivot/model.ts:638

Parameters

ParameterType
dataIPivotTableSnapshot

Returns

void


getDirty()

getDirty(): boolean

Defined in: pivot/model.ts:122

  • get the dirty status of the pivot table.

Returns

boolean

  • The dirty status of the pivot table.

getFieldById()

getFieldById(fieldId): 
  | undefined
  | PivotTableValueField
  | PivotTableLabelField

Defined in: pivot/model.ts:380

Parameters

ParameterType
fieldIdstring

Returns

| undefined | PivotTableValueField | PivotTableLabelField


getFieldFormat()

getFieldFormat(fieldId): undefined | string

Defined in: pivot/model.ts:180

Parameters

ParameterType
fieldIdstring

Returns

undefined | string


getFieldPositionInfoById()

getFieldPositionInfoById(fieldId): {
  area:   | undefined
     | PivotTableFiledAreaEnum;
  index: number;
}

Defined in: pivot/model.ts:321

Parameters

ParameterTypeDescription
fieldIdstringThe 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.

NameTypeDefined in
area| undefined | PivotTableFiledAreaEnumpivot/model.ts:321
indexnumberpivot/model.ts:321

Description

Get where the field bo be position info by field id.


getFieldsAreaByType()

getFieldsAreaByType(type): string[]

Defined in: pivot/model.ts:365

Parameters

ParameterType
typePivotTableFiledAreaEnum

Returns

string[]


getFilterInfo()

getFilterInfo(fieldId): 
  | undefined
  | IPivotTableFilterInfo

Defined in: pivot/model.ts:226

Parameters

ParameterType
fieldIdstring

Returns

| undefined | IPivotTableFilterInfo


getOptions()

getOptions(): IPivotTableOptions

Defined in: pivot/model.ts:145

  • Get the options of the pivot table. It is a copy of the options.

Returns

IPivotTableOptions

  • The options of the pivot table.

getQueryData()

getQueryData(): IPivotTableQueryData

Defined in: pivot/model.ts:599

Represents the query data of the pivot table.Which is used to query the data from the data collection.

Returns

IPivotTableQueryData

  • The query data of the pivot table.

getSortInfo()

getSortInfo(fieldId): 
  | undefined
  | IPivotTableSortInfo

Defined in: pivot/model.ts:219

Parameters

ParameterType
fieldIdstring

Returns

| undefined | IPivotTableSortInfo


getValueIndex()

getValueIndex(): number

Defined in: pivot/model.ts:537

  • The special ΣValue fields order index in the dimension fields

Returns

number

the index


getValuePosition()

getValuePosition(): PivotTableValuePositionEnum

Defined in: pivot/model.ts:541

Returns

PivotTableValuePositionEnum


isColMultiMeasure()

isColMultiMeasure(): boolean

Defined in: pivot/model.ts:549

  • Whether the pivot table has the special ΣValue fields in column area.

Returns

boolean

  • has or not.

isEmpty()

isEmpty(): boolean

Defined in: pivot/model.ts:573

Returns

boolean


isExistFieldName()

isExistFieldName(fieldName): boolean

Defined in: pivot/model.ts:390

Parameters

ParameterType
fieldNamestring

Returns

boolean


isRowMultiMeasure()

isRowMultiMeasure(): boolean

Defined in: pivot/model.ts:566

  • Whether the pivot table has the special ΣValue fields in row area.

Returns

boolean

  • has or not.

iterateField()

iterateField(callback): void

Defined in: pivot/model.ts:233

Parameters

ParameterType
callback(field) => void

Returns

void


iterateFieldByArea()

iterateFieldByArea(area, callback): void

Defined in: pivot/model.ts:254

Parameters

ParameterType
areaPivotTableFiledAreaEnum
callback(field) => void

Returns

void


iterateFieldDim()

iterateFieldDim(callback): void

Defined in: pivot/model.ts:242

Parameters

ParameterType
callback(field) => void

Returns

void


iterateFieldMeasure()

iterateFieldMeasure(callback): void

Defined in: pivot/model.ts:248

Parameters

ParameterType
callback(field) => void

Returns

void


removeField()

removeField(fieldId): void

Defined in: pivot/model.ts:441

Parameters

ParameterTypeDescription
fieldIdstringThe id of the field to be removed.

Returns

void

-void

Description

Remove a field from the pivot table by the field id.


renameField()

renameField(fieldId, displayName): void

Defined in: pivot/model.ts:410

Parameters

ParameterTypeDescription
fieldIdstringThe id of the field to be renamed.
displayNamestringThe new display name of the field.

Returns

void

Description

Rename a field in the pivot table.


setCollapse()

setCollapse(
   fieldId, 
   collapse, 
   item?): void

Defined in: pivot/model.ts:155

Parameters

ParameterTypeDescription
fieldIdstringThe id of the field.
collapsebooleanThe collapse status of the field.
item?stringThe 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/model.ts:114

  • set a dirty status to flag the pivot table whether it is changed.

Parameters

ParameterType
dirtyboolean

Returns

void


setFieldFormat()

setFieldFormat(fieldId, format): void

Defined in: pivot/model.ts:190

Parameters

ParameterType
fieldIdstring
formatundefined | string

Returns

void


setFilterInfo()

setFilterInfo(fieldId, filterInfo): void

Defined in: pivot/model.ts:168

Parameters

ParameterType
fieldIdstring
filterInfoIPivotTableFilterInfo

Returns

void


setOptions()

setOptions(options): void

Defined in: pivot/model.ts:131

  • Set the options of the pivot table.

Parameters

ParameterTypeDescription
optionsIPivotTableOptionsThe options to be set.

Returns

void


setSortInfo()

setSortInfo(fieldId, sortInfo): void

Defined in: pivot/model.ts:206

Parameters

ParameterType
fieldIdstring
sortInfo| undefined | IPivotTableSortInfo

Returns

void


setSubtotalType()

setSubtotalType(tableFieldId, subtotal): void

Defined in: pivot/model.ts:582

  • set or update a field’s subtotal type. , the table field must in the value area.

Parameters

ParameterTypeDescription
tableFieldIdstringThe id of the pivot table field.
subtotalPivotSubtotalTypeEnumThe subtotal type.

Returns

void


startChangeStack()

startChangeStack(): void

Defined in: pivot/model.ts:99

Returns

void


toJSON()

toJSON(): IPivotTableSnapshot

Defined in: pivot/model.ts:667

Returns

IPivotTableSnapshot


updateFieldPosition()

updateFieldPosition(
   fieldId, 
   area, 
   index): void

Defined in: pivot/model.ts:465

Parameters

ParameterType
fieldIdstring
areaPivotTableFiledAreaEnum
indexnumber

Returns

void


updateFieldSourceInfo()

updateFieldSourceInfo(
   fieldId, 
   sourceName, 
   dataFieldId): void

Defined in: pivot/model.ts:343

Parameters

ParameterType
fieldIdstring
sourceNamestring
dataFieldIdstring

Returns

void


updateValuePosition()

updateValuePosition(valuePosition, valueIndex): void

Defined in: pivot/model.ts:522

  • Update the value position of the pivot table.

Parameters

ParameterType
valuePositionPivotTableValuePositionEnum
valueIndexnumber

Returns

void