@univerjs-pro/engine-pivot v0.5.4


Class: DataField

Defined in: field/data-field.ts:12

Represents a data field in a pivot table , it match the excel pivot cache field data structure.

Param

The unique identifier of the data field.

Param

The name of the data field. Almost is the row header of pivot table data source, the custom field such as calculated field or grouped field will have a different name.

Method

addRecord - Add a record to the data field.

Constructors

new DataField()

new DataField(
   id, 
   name, 
   hexCode): DataField

Defined in: field/data-field.ts:97

Parameters

ParameterType
idstring
namestring
hexCodestring

Returns

DataField

Properties

PropertyModifierTypeDefault valueDefined in
formatpublicstring''field/data-field.ts:69
hasBlankpublicbooleanfalsefield/data-field.ts:61
hasDatepublicbooleanfalsefield/data-field.ts:57
hasDecimalpublicbooleanfalsefield/data-field.ts:53
hasIntegerpublicbooleanfalsefield/data-field.ts:49
hasTextpublicbooleanfalsefield/data-field.ts:65
hexCodepublicstringundefinedfield/data-field.ts:24
idreadonlystringundefinedfield/data-field.ts:16
itemspublicstring[][]field/data-field.ts:36
itemTypespublicPivotDataFieldDataTypeEnum[][]field/data-field.ts:41
maxDatepublicnumberNumber.NaNfield/data-field.ts:81
maxNumberpublicnumberNumber.NaNfield/data-field.ts:73
minDatepublicnumberNumber.NaNfield/data-field.ts:85
minNumberpublicnumberNumber.NaNfield/data-field.ts:77
namepublicstringundefinedfield/data-field.ts:20
rangeKeypublicstringundefinedfield/data-field.ts:28
recordspublicIDataFieldValue[][]field/data-field.ts:32

Methods

addRecord()

addRecord(record, index): void

Defined in: field/data-field.ts:200

Parameters

ParameterTypeDescription
recordIDataFieldValueThe record to be added.
indexnumberThe index of the record.

Returns

void

Description

Add a record to the data field.


fromJSON()

fromJSON(data): void

Defined in: field/data-field.ts:339

Parameters

ParameterType
dataIDataFieldJSON

Returns

void


getFieldDataType()

getFieldDataType(): PivotDataFieldDataTypeEnum

Defined in: field/data-field.ts:140

  • if the field contains date value and blank only, the field data type is date. if the field contains number value and blank only, the field data type is number. otherwise, the field data type is text.

Returns

PivotDataFieldDataTypeEnum

the name of the data field.


getFieldInfo()

getFieldInfo(): IDataFieldInfo

Defined in: field/data-field.ts:294

Returns

IDataFieldInfo

The data field info.

Description

Get the data field info for pivot table, some properties are not included in the data field info because they are not necessary for the pivot table. only the import/export need them.


getformat()

getformat(): string

Defined in: field/data-field.ts:112

Returns

string


getId()

getId(): string

Defined in: field/data-field.ts:124

Returns

string


getIndexesByKey()

getIndexesByKey(key): number[]

Defined in: field/data-field.ts:218

Parameters

ParameterType
keystring

Returns

number[]


getItemKey()

getItemKey(index): string

Defined in: field/data-field.ts:165

  • Returns the key of the data field item. the key logic should be same with addRecord method.

Parameters

ParameterTypeDescription
indexnumberthe index of data records

Returns

string

The key of the data field item.


getItemSharedKey()

getItemSharedKey(key): string

Defined in: field/data-field.ts:156

  • Returns the shared key with the data field item, this can be combined in the tuple group with other data field item key to create a unique path.

Parameters

ParameterType
keystring

Returns

string

key with field and item info


getItemsMap()

getItemsMap(): Record<string, number>

Defined in: field/data-field.ts:286

Returns

Record<string, number>


getName()

getName(): string

Defined in: field/data-field.ts:128

Returns

string


getRangeKey()

getRangeKey(): string

Defined in: field/data-field.ts:108

  • Returns the name of the data field.

Returns

string

the range key of the data field.


getTypeByKey()

getTypeByKey(key): PivotDataFieldDataTypeEnum

Defined in: field/data-field.ts:181

  • get the type of date by key

Parameters

ParameterTypeDescription
keystringthe key of the data field item.

Returns

PivotDataFieldDataTypeEnum

the data type


getValue()

getValue(index): IDataFieldValue

Defined in: field/data-field.ts:190

  • Returns the value of the data field record

Parameters

ParameterTypeDescription
indexnumberThe index of the data field record.

Returns

IDataFieldValue

  • The value of the data field record.

reset()

reset(): void

Defined in: field/data-field.ts:365

Returns

void


setName()

setName(name): void

Defined in: field/data-field.ts:132

Parameters

ParameterType
namestring

Returns

void


setRangeKey()

setRangeKey(rangeKey): void

Defined in: field/data-field.ts:120

  • set the range key of the data field.

Parameters

ParameterTypeDescription
rangeKeystringthe range key of the data field.

Returns

void


toJSON()

toJSON(): IDataFieldJSON

Defined in: field/data-field.ts:309

Returns

IDataFieldJSON