@univerjs-pro/engine-pivot v0.5.0-beta.1Docs


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

PivotModel

Defined in

pivot/model.ts:91

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

Parameters

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

Defined in

pivot/model.ts:270


cloneBufferModel()

cloneBufferModel(): PivotModel

Returns

PivotModel

Defined in

pivot/model.ts:694


endChangeStack()

endChangeStack(): IPivotTableChangeSet[]

Returns

IPivotTableChangeSet[]

Defined in

pivot/model.ts:103


fromJSON()

fromJSON(data): void

Parameters

ParameterType
dataIPivotTableSnapshot

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

ParameterType
fieldIdstring

Returns

undefined | PivotTableValueField | PivotTableLabelField

Defined in

pivot/model.ts:380


getFieldFormat()

getFieldFormat(fieldId): undefined | string

Parameters

ParameterType
fieldIdstring

Returns

undefined | string

Defined in

pivot/model.ts:180


getFieldPositionInfoById()

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

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
areaundefined | PivotTableFiledAreaEnumpivot/model.ts:321
indexnumberpivot/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

ParameterType
typePivotTableFiledAreaEnum

Returns

string[]

Defined in

pivot/model.ts:365


getFilterInfo()

getFilterInfo(fieldId): undefined | IPivotTableFilterInfo

Parameters

ParameterType
fieldIdstring

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

IPivotTableOptions

  • 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

IPivotTableQueryData

  • The query data of the pivot table.

Defined in

pivot/model.ts:599


getSortInfo()

getSortInfo(fieldId): undefined | IPivotTableSortInfo

Parameters

ParameterType
fieldIdstring

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

PivotTableValuePositionEnum

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

ParameterType
fieldNamestring

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

ParameterType
callback(field) => void

Returns

void

Defined in

pivot/model.ts:233


iterateFieldByArea()

iterateFieldByArea(area, callback): void

Parameters

ParameterType
areaPivotTableFiledAreaEnum
callback(field) => void

Returns

void

Defined in

pivot/model.ts:254


iterateFieldDim()

iterateFieldDim(callback): void

Parameters

ParameterType
callback(field) => void

Returns

void

Defined in

pivot/model.ts:242


iterateFieldMeasure()

iterateFieldMeasure(callback): void

Parameters

ParameterType
callback(field) => void

Returns

void

Defined in

pivot/model.ts:248


removeField()

removeField(fieldId): void

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.

Defined in

pivot/model.ts:441


renameField()

renameField(fieldId, displayName): void

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.

Defined in

pivot/model.ts:410


setCollapse()

setCollapse(
   fieldId, 
   collapse, 
   item?): void

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.

Defined in

pivot/model.ts:155


setDirty()

setDirty(dirty): void
  • set a dirty status to flag the pivot table whether it is changed.

Parameters

ParameterType
dirtyboolean

Returns

void

Defined in

pivot/model.ts:114


setFieldFormat()

setFieldFormat(fieldId, format): void

Parameters

ParameterType
fieldIdstring
formatundefined | string

Returns

void

Defined in

pivot/model.ts:190


setFilterInfo()

setFilterInfo(fieldId, filterInfo): void

Parameters

ParameterType
fieldIdstring
filterInfoIPivotTableFilterInfo

Returns

void

Defined in

pivot/model.ts:168


setOptions()

setOptions(options): void
  • Set the options of the pivot table.

Parameters

ParameterTypeDescription
optionsIPivotTableOptionsThe options to be set.

Returns

void

Defined in

pivot/model.ts:131


setSortInfo()

setSortInfo(fieldId, sortInfo): void

Parameters

ParameterType
fieldIdstring
sortInfoundefined | 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

ParameterTypeDescription
tableFieldIdstringThe id of the pivot table field.
subtotalPivotSubtotalTypeEnumThe 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

IPivotTableSnapshot

Defined in

pivot/model.ts:667


updateFieldPosition()

updateFieldPosition(
   fieldId, 
   area, 
   index): void

Parameters

ParameterType
fieldIdstring
areaPivotTableFiledAreaEnum
indexnumber

Returns

void

Defined in

pivot/model.ts:465


updateFieldSourceInfo()

updateFieldSourceInfo(
   fieldId, 
   sourceName, 
   dataFieldId): void

Parameters

ParameterType
fieldIdstring
sourceNamestring
dataFieldIdstring

Returns

void

Defined in

pivot/model.ts:343


updateValuePosition()

updateValuePosition(valuePosition, valueIndex): void
  • Update the value position of the pivot table.

Parameters

ParameterType
valuePositionPivotTableValuePositionEnum
valueIndexnumber

Returns

void

Defined in

pivot/model.ts:522