@univerjs-pro/engine-pivot v0.5.0-beta.1 • Docs
Class: DataField
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
Parameters
Parameter | Type |
---|---|
id | string |
name | string |
hexCode | string |
Returns
Defined in
field/data-field.ts:97
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
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.
Defined in
field/data-field.ts:200
fromJSON()
fromJSON(data): void
Parameters
Parameter | Type |
---|---|
data | IDataFieldJSON |
Returns
void
Defined in
field/data-field.ts:339
getFieldDataType()
getFieldDataType(): PivotDataFieldDataTypeEnum
- 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.
Defined in
field/data-field.ts:140
getFieldInfo()
getFieldInfo(): IDataFieldInfo
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.
Defined in
field/data-field.ts:294
getformat()
getformat(): string
Returns
string
Defined in
field/data-field.ts:112
getId()
getId(): string
Returns
string
Defined in
field/data-field.ts:124
getIndexesByKey()
getIndexesByKey(key): number[]
Parameters
Parameter | Type |
---|---|
key | string |
Returns
number
[]
Defined in
field/data-field.ts:218
getItemKey()
getItemKey(index): string
- 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.
Defined in
field/data-field.ts:165
getItemSharedKey()
getItemSharedKey(key): string
- 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
Defined in
field/data-field.ts:156
getItemsMap()
getItemsMap(): Record<string, number>
Returns
Record
<string
, number
>
Defined in
field/data-field.ts:286
getName()
getName(): string
Returns
string
Defined in
field/data-field.ts:128
getRangeKey()
getRangeKey(): string
- Returns the name of the data field.
Returns
string
the range key of the data field.
Defined in
field/data-field.ts:108
getTypeByKey()
getTypeByKey(key): PivotDataFieldDataTypeEnum
- get the type of date by key
Parameters
Parameter | Type | Description |
---|---|---|
key | string | the key of the data field item. |
Returns
the data type
Defined in
field/data-field.ts:181
getValue()
getValue(index): IDataFieldValue
- 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.
Defined in
field/data-field.ts:190
reset()
reset(): void
Returns
void
Defined in
field/data-field.ts:365
setName()
setName(name): void
Parameters
Parameter | Type |
---|---|
name | string |
Returns
void
Defined in
field/data-field.ts:132
setRangeKey()
setRangeKey(rangeKey): void
- set the range key of the data field.
Parameters
Parameter | Type | Description |
---|---|---|
rangeKey | string | the range key of the data field. |
Returns
void
Defined in
field/data-field.ts:120
toJSON()
toJSON(): IDataFieldJSON
Returns
Defined in
field/data-field.ts:309