@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
Parameter | Type |
---|---|
id | string |
name | string |
hexCode | string |
Returns
Properties
Property | Modifier | Type | Default value | Defined in |
---|---|---|---|---|
format | public | string | '' | field/data-field.ts:69 |
hasBlank | public | boolean | false | field/data-field.ts:61 |
hasDate | public | boolean | false | field/data-field.ts:57 |
hasDecimal | public | boolean | false | field/data-field.ts:53 |
hasInteger | public | boolean | false | field/data-field.ts:49 |
hasText | public | boolean | false | field/data-field.ts:65 |
hexCode | public | string | undefined | field/data-field.ts:24 |
id | readonly | string | undefined | field/data-field.ts:16 |
items | public | string [] | [] | field/data-field.ts:36 |
itemTypes | public | PivotDataFieldDataTypeEnum [] | [] | field/data-field.ts:41 |
maxDate | public | number | Number.NaN | field/data-field.ts:81 |
maxNumber | public | number | Number.NaN | field/data-field.ts:73 |
minDate | public | number | Number.NaN | field/data-field.ts:85 |
minNumber | public | number | Number.NaN | field/data-field.ts:77 |
name | public | string | undefined | field/data-field.ts:20 |
rangeKey | public | string | undefined | field/data-field.ts:28 |
records | public | IDataFieldValue [] | [] | field/data-field.ts:32 |
Methods
addRecord()
addRecord(record, index): void
Defined in: field/data-field.ts:200
Parameters
Parameter | Type | Description |
---|---|---|
record | IDataFieldValue | The record to be added. |
index | number | The 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
Parameter | Type |
---|---|
data | IDataFieldJSON |
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
the name of the data field.
getFieldInfo()
getFieldInfo(): IDataFieldInfo
Defined in: field/data-field.ts:294
Returns
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
Parameter | Type |
---|---|
key | string |
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
Parameter | Type | Description |
---|---|---|
index | number | the 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
Parameter | Type |
---|---|
key | string |
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
Parameter | Type | Description |
---|---|---|
key | string | the key of the data field item. |
Returns
the data type
getValue()
getValue(index): IDataFieldValue
Defined in: field/data-field.ts:190
- Returns the value of the data field record
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the data field record. |
Returns
- 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
Parameter | Type |
---|---|
name | string |
Returns
void
setRangeKey()
setRangeKey(rangeKey): void
Defined in: field/data-field.ts:120
- set the range key of the data field.
Parameters
Parameter | Type | Description |
---|---|---|
rangeKey | string | the range key of the data field. |
Returns
void
toJSON()
toJSON(): IDataFieldJSON
Defined in: field/data-field.ts:309