@univerjs-pro/engine-pivot 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ import { IColumnNodeSizeInfo, INodeSizeInfo, IPivotLayoutCtx, IPivotTableLabelFieldQueryData, IPivotTableQueryData } from '../types';
2
+ import { SummaryManager } from '../summary/summary-manager';
3
+ import { NodeTree } from '../summary/node-tree';
4
+ import { PivotTable } from '../pivot/pivot-table';
5
+ import { PageViewItem } from './pivot-view';
6
+ export declare class BaseLayout {
7
+ /**
8
+ *
9
+ * @param pivotTable - the pivot table
10
+ * @param summaryManager - the summary manager
11
+ * @returns {IPivotLayoutCtx} the layout context
12
+ */
13
+ static prepareLayoutCtx(pivotTable: PivotTable, summaryManager: SummaryManager, queryData: IPivotTableQueryData): IPivotLayoutCtx;
14
+ static layoutPage(ctx: IPivotLayoutCtx): void;
15
+ static layoutPageOverThenDown(filters: IPivotTableLabelFieldQueryData[], page: PageViewItem, pageWrap?: number): void;
16
+ static layoutPageDownThenOver(filters: IPivotTableLabelFieldQueryData[], page: PageViewItem, pageWrap?: number): void;
17
+ static layoutCol(ctx: IPivotLayoutCtx): void;
18
+ static layoutCorner(ctx: IPivotLayoutCtx): void;
19
+ static layoutColHeader(ctx: IPivotLayoutCtx): void;
20
+ static setValueSize(ctx: IPivotLayoutCtx): void;
21
+ static layoutNoneColFields(ctx: IPivotLayoutCtx, nodeTree: NodeTree): {
22
+ itemSize: number;
23
+ topTotalSize: number;
24
+ bottomTotalSize: number;
25
+ colPathMap: Record<string, number>;
26
+ };
27
+ static layoutColFields(ctx: IPivotLayoutCtx): void;
28
+ /**
29
+ * - the node is leaf node when the level of the node is equal to the deep, but the node is not the real leaf node
30
+ * @param {NodeTree} nodeTree - the node tree
31
+ * @param {number} deep - the deep of the tree
32
+ * @returns {boolean} - the node is leaf node or not
33
+ */
34
+ static isLeafNode(nodeTree: NodeTree, deep: number): boolean;
35
+ static getRealSize(sizeInfo: INodeSizeInfo): number;
36
+ /**
37
+ * - get the node value from the summary manager, the node index is the tuples of summary manager
38
+ * @param {IPivotLayoutCtx} ctx
39
+ * @param {NodeTree} nodeTree
40
+ * @param {number} measureIndex
41
+ * @returns {number} - the value of the node
42
+ */
43
+ static getNodeValue(ctx: IPivotLayoutCtx, nodeTree: NodeTree, measureIndex: number): number | {
44
+ errorType: import('../types').PivotErrorTypeEnum;
45
+ } | undefined;
46
+ static doColLeafNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, col: number, valueIds: string[]): IColumnNodeSizeInfo;
47
+ static buildColPathMap(ctx: IPivotLayoutCtx, nodeTree: NodeTree): Record<string, number>;
48
+ static iterateColLeafNodeChildren(ctx: IPivotLayoutCtx, nodeTree: NodeTree, paths: string[], map: Record<string, number>): void;
49
+ /**
50
+ * - build the path map for the collapse node
51
+ * @param ctx - the layout context
52
+ * @param nodeTree - the node tree
53
+ * @param colPathMapList - the path map list
54
+ */
55
+ static buildColPathMapForCollapse(ctx: IPivotLayoutCtx, nodeTree: NodeTree, colPathMapList: Record<string, number>[]): void;
56
+ static doColBranchNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, col: number, valueIds: string[]): IColumnNodeSizeInfo;
57
+ static shouldMultipleTotal(hasMultiValue: boolean, nodeLevel: number, valueIndex: number): boolean;
58
+ static shouldMultipleNode(hasMultiValue: boolean, nodeLevel: number, valueIndex: number): boolean;
59
+ static getRowIndexForColHeader(nodeLevel: number, valueIndex: number, hasMultiValue: boolean): number;
60
+ static layoutColNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, col: number, valueIds: string[]): IColumnNodeSizeInfo;
61
+ static getMeasureIndex(isColMultiMeasure: boolean, valueIds: string[], measureIndexesMap: Record<string, number>): number;
62
+ static updateColumnSubtotal(ctx: IPivotLayoutCtx, col: number, nodeTree: NodeTree, valueIds: string[], colPathMap: Record<string, number>): void;
63
+ }
@@ -0,0 +1,8 @@
1
+ import { PivotTable } from '../pivot/pivot-table';
2
+ import { SummaryManager } from '../summary/summary-manager';
3
+ import { IPivotLayoutCtx, IPivotTableQueryData } from '../types';
4
+ import { BaseLayout } from './base-layout';
5
+ export declare class CompactLayout extends BaseLayout {
6
+ static layout(pivotTable: PivotTable, SummaryManager: SummaryManager, queryData: IPivotTableQueryData): import('./pivot-view').PivotView;
7
+ static layoutRow(ctx: IPivotLayoutCtx): void;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { PivotTable } from '../pivot/pivot-table';
2
+ import { SummaryManager } from '../summary/summary-manager';
3
+ import { IPivotLayoutCtx, IPivotTableQueryData } from '../types';
4
+ import { BaseLayout } from './base-layout';
5
+ export declare class OutlineLayout extends BaseLayout {
6
+ static layout(pivotTable: PivotTable, SummaryManager: SummaryManager, queryData: IPivotTableQueryData): import('./pivot-view').PivotView;
7
+ static layoutRow(ctx: IPivotLayoutCtx): void;
8
+ }
@@ -0,0 +1,125 @@
1
+ import { PivotModel } from '../pivot/model';
2
+ import { ILabelViewHeaderMapItem, ILabelViewItemJSON, IPageViewItemJSON, IPageViewItemRange, IPivotViewErrorValue, IPivotViewInfo, IPivotViewItemData, IPivotViewItemJSON, IPivotViewJSON, IPivotViewPrefixValue, IPivotViewValueType, PivotCellStyleTypeEnum } from '../types';
3
+ /**
4
+ * @class PivotView
5
+ * @description the view of pivot table, which contains the page, row, col, data view, the page view separation the pivot table to two areas, the row and col view as the header of data area
6
+ */
7
+ export declare class PivotView {
8
+ /**
9
+ * the page view of the pivot table
10
+ */
11
+ pageView: PageViewItem;
12
+ /**
13
+ * the row view of the pivot table
14
+ */
15
+ rowView: LabelViewItem;
16
+ /**
17
+ * the col view of the pivot table
18
+ */
19
+ colView: LabelViewItem;
20
+ /**
21
+ * the data view of the pivot table
22
+ */
23
+ dataView: PivotViewItem;
24
+ /**
25
+ * the corner view of the pivot table
26
+ */
27
+ cornerView: PivotViewItem;
28
+ /**
29
+ * the version of the pivot view, it will be used to check the view is the latest
30
+ */
31
+ version: number;
32
+ /**
33
+ * the format map of the table field id, it will be used to store the format of the pivot view
34
+ */
35
+ formatMap: Record<string, string>;
36
+ constructor();
37
+ setVersion(version?: number): void;
38
+ /**
39
+ * - the func effect is to set the format code , for label view, it will used to format the header , such as date type data, in the data view, it will used to format the data of show data as
40
+ * @param model the pivot model, it will be used to set the format of the pivot view
41
+ */
42
+ setFormat(model: PivotModel): void;
43
+ getVersion(): number;
44
+ toJSON(): IPivotViewJSON;
45
+ formJSON(data: IPivotViewJSON): void;
46
+ }
47
+ export declare class PivotViewItem {
48
+ /**
49
+ * - how many rows in the view
50
+ */
51
+ rowCount: number;
52
+ /**
53
+ * - how many cols in the view
54
+ */
55
+ colCount: number;
56
+ /**
57
+ * the data of the view, the key is the row index, the value is the column data
58
+ */
59
+ data: IPivotViewItemData;
60
+ /**
61
+ * the info of the view, the index is the index of the view item, the value is the info of the view item
62
+ */
63
+ info: IPivotViewInfo[];
64
+ lastCol: number;
65
+ lastRow: number;
66
+ setValue(row: number, col: number, value: IPivotViewValueType): void;
67
+ setStyle(row: number, col: number, styleType: PivotCellStyleTypeEnum): void;
68
+ setBlank(row: number, col: number): void;
69
+ protected getCell(row: number, col: number): import('../types').IPivotViewCellData;
70
+ setInfo(index: number, info: IPivotViewInfo): void;
71
+ buildPathMap(considerValue: boolean): Record<string, number>;
72
+ setRowCount(rowCount: number): void;
73
+ setColCount(colCount: number): void;
74
+ getValue(row: number, col: number): IPivotViewValueType;
75
+ getStyle(row: number, col: number): PivotCellStyleTypeEnum | undefined;
76
+ toJSON(): IPivotViewItemJSON;
77
+ fromJSON(json: IPivotViewItemJSON): void;
78
+ }
79
+ export declare class PageViewItem extends PivotViewItem {
80
+ /**
81
+ * the range group of the page view, all range is base on the left top of the page view
82
+ */
83
+ ranges: IPageViewItemRange[];
84
+ /**
85
+ * the last col index of the page view
86
+ */
87
+ lastCol: number;
88
+ /**
89
+ * the last row index of the page view
90
+ */
91
+ lastRow: number;
92
+ setPageIndex(row: number, col: number, index: number): void;
93
+ addRange(range: IPageViewItemRange): void;
94
+ getRanges(): IPageViewItemRange[];
95
+ setLastCol(col: number): void;
96
+ setLastRow(row: number): void;
97
+ getLastCol(): number;
98
+ getLastRow(): number;
99
+ toJSON(): IPageViewItemJSON;
100
+ fromJSON(json: IPageViewItemJSON): void;
101
+ }
102
+ export declare class LabelViewItem extends PivotViewItem {
103
+ /**
104
+ * this property is used to store the header map of the label view
105
+ * - in the row view, the header map saved the every column in row view, the key is the column index, the value is the header map item
106
+ * - in the col view, the header map saved the every row in col view, the key is the row index, the value is the header map item
107
+ */
108
+ headerMap: ILabelViewHeaderMapItem[];
109
+ addHeaderMapItem(index: number, item: ILabelViewHeaderMapItem): void;
110
+ getHeaderMapItem(index: number): ILabelViewHeaderMapItem;
111
+ toJSON(): ILabelViewItemJSON;
112
+ fromJSON(json: ILabelViewItemJSON): void;
113
+ }
114
+ /**
115
+ * judge the value is the prefix value, once when the value is a subtotal and there are multiple value field, the value will be the prefix value
116
+ * @param {IPivotViewValueType} value the pivot view value
117
+ * @returns {boolean} the value is the prefix value
118
+ */
119
+ export declare const isPrefixValue: (value: IPivotViewValueType) => value is IPivotViewPrefixValue;
120
+ /**
121
+ * judge the value is the error value, it will be a error value when the show data as or the product bigger than the max value of number in javascript
122
+ * @param {IPivotViewValueType} value - the pivot view value
123
+ * @returns {boolean} the value is the error value
124
+ */
125
+ export declare const isErrorValue: (value: IPivotViewValueType) => value is IPivotViewErrorValue;
@@ -0,0 +1,41 @@
1
+ import { PivotTable } from '../pivot/pivot-table';
2
+ import { NodeTree } from '../summary/node-tree';
3
+ import { SummaryManager } from '../summary/summary-manager';
4
+ import { INodeSizeInfo, IPivotLayoutCtx, IPivotTableQueryData, IPivotTableValueFieldQueryData, IPivotViewInfo } from '../types';
5
+ import { BaseLayout } from './base-layout';
6
+ export declare class TabularLayout extends BaseLayout {
7
+ static layout(pivotTable: PivotTable, summaryManager: SummaryManager, queryData: IPivotTableQueryData): import('./pivot-view').PivotView;
8
+ static layoutCorner(ctx: IPivotLayoutCtx): void;
9
+ static layoutRowFields(ctx: IPivotLayoutCtx): void;
10
+ static doRowLeafNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): {
11
+ itemSize: number;
12
+ topTotalSize: number;
13
+ bottomTotalSize: number;
14
+ valueIndex?: undefined;
15
+ } | {
16
+ itemSize: number;
17
+ topTotalSize: number;
18
+ bottomTotalSize: number;
19
+ valueIndex: number;
20
+ };
21
+ /**
22
+ * - layout the data area of the pivot table
23
+ * @param {IPivotLayoutCtx} ctx the context of layout
24
+ * @param {NodeTree} nodeTree the current node
25
+ * @param {number} row the current row index
26
+ * @param {number} measureIndex the current measure index, if the row does not have multiple measures, the measureIndex is -1
27
+ */
28
+ static startContent(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, measureIndex: number): void;
29
+ static layoutValueNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, measureIndex: number, paths: string[]): void;
30
+ static layoutValueNodeSubtotal(ctx: IPivotLayoutCtx, row: number): void;
31
+ static getMeasureInfoByIndex(ctx: IPivotLayoutCtx, valueQueryInfo: IPivotTableValueFieldQueryData[], rowInfo: IPivotViewInfo, colInfo: IPivotViewInfo): IPivotTableValueFieldQueryData;
32
+ static layoutValueLeafNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, paths: string[], measureIndex: number): void;
33
+ static getColIndexForRowHeader(nodeLevel: number, valueIndex: number, hasMultiValue: boolean): number;
34
+ static doRowBrachNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): {
35
+ itemSize: number;
36
+ topTotalSize: number;
37
+ bottomTotalSize: number;
38
+ };
39
+ static layoutRowNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): INodeSizeInfo;
40
+ static updateRowSubtotal(ctx: IPivotLayoutCtx, row: number, nodeTree: NodeTree, valueIds: string[]): void;
41
+ }
@@ -0,0 +1,198 @@
1
+ import { IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, PivotSubtotalTypeEnum, PivotLayoutTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '../types';
2
+ import { PivotTableLabelField, PivotTableValueField } from './table-field';
3
+ /**
4
+ * @class PivotModel represents a config model for a pivot table.
5
+ * @description The pivot model is a class that stores the pivot table's configuration information.
6
+ * @typedef PivotModel
7
+ * @property {string[]} rowFields - An array of row fields id.
8
+ * @property {string[]} columnFields - An array of column fields id.
9
+ * @property {string[]} valueFields - An array of value fields id.
10
+ * @property {string[]} filterFields - An array of filter fields id.
11
+ * @property {string[]} hiddenFields - An array of hidden fields id.
12
+ * @property {Record<string, PivotTableLabelField>} dimension - A object of dimension fields, which key is the field id and value is the field.
13
+ * @property {Record<string, PivotTableValueField>} measure - A object of measure fields, which key is the field id and value is the field.
14
+ * @property {number} valueIndex - The special ΣValue fields order index in the dimension fields
15
+ * @property {PivotTableValuePositionEnum} valuePosition - The special ΣValue fields position in row or column area.
16
+ * @property {PivotLayoutTypeEnum} layout - The layout type of the pivot table.
17
+ * @property {Record<string, any>} collapseInfo - The collapse information of the pivot table. Which data structure is {fieldId: boolean | {item: boolean}}
18
+ */
19
+ export declare class PivotModel {
20
+ /**
21
+ *@property An array of row fields id.
22
+ */
23
+ rowFields: string[];
24
+ /**
25
+ *@property An array of column fields id.
26
+ */
27
+ columnFields: string[];
28
+ /**
29
+ *@property An array of value fields id.
30
+ */
31
+ valueFields: string[];
32
+ /**
33
+ *@property An array of filter fields id.
34
+ */
35
+ filterFields: string[];
36
+ /**
37
+ *@property An array of hidden fields id.
38
+ */
39
+ hiddenFields: string[];
40
+ /**
41
+ *@property An array of dimension fields.
42
+ */
43
+ dimension: Record<string, PivotTableLabelField>;
44
+ /**
45
+ *@property An array of measure fields.
46
+ */
47
+ measure: Record<string, PivotTableValueField>;
48
+ /**
49
+ *@property The special ΣValue fields order index in the dimension fields.
50
+ *@description The special ΣValue fields order index in the dimension fields, the index value is equal to the index of the field in the row or column area which the ΣValue field followed.
51
+ */
52
+ valueIndex: number;
53
+ /**
54
+ *@property The special ΣValue fields position in row or column area.
55
+ */
56
+ valuePosition: PivotTableValuePositionEnum;
57
+ /**
58
+ *@property The layout type of the pivot table.
59
+ */
60
+ layout: PivotLayoutTypeEnum;
61
+ /**
62
+ * @property The collapse information of the pivot table.
63
+ */
64
+ collapseInfo: Record<string, boolean | Record<string, boolean>>;
65
+ /**
66
+ * Creates an instance of PivotModel.
67
+ */
68
+ options: IPivotTableOptions;
69
+ _changeStack: IPivotTableChangeSet[];
70
+ /**
71
+ * the dirty status is used to flag the pivot table need to be queried data from the data source or just use cached tuple data.
72
+ */
73
+ private _isDirty;
74
+ constructor();
75
+ startChangeStack(): void;
76
+ endChangeStack(): IPivotTableChangeSet[];
77
+ /**
78
+ * - set a dirty status to flag the pivot table whether it is changed.
79
+ * @param {boolean} dirty
80
+ */
81
+ setDirty(dirty: boolean): void;
82
+ /**
83
+ * - get the dirty status of the pivot table.
84
+ * @returns {boolean} - The dirty status of the pivot table.
85
+ */
86
+ getDirty(): boolean;
87
+ /**
88
+ * - Set the options of the pivot table.
89
+ * @param {IPivotTableOptions} options - The options to be set.
90
+ * @returns {void}
91
+ */
92
+ setOptions(options: IPivotTableOptions): void;
93
+ /**
94
+ * - Get the options of the pivot table. It is a copy of the options.
95
+ * @returns {IPivotTableOptions} - The options of the pivot table.
96
+ */
97
+ getOptions(): {
98
+ pageWrap?: number;
99
+ pageOverThenDown?: boolean;
100
+ showColHeaders?: boolean;
101
+ showColStripes?: boolean;
102
+ showLastColumn?: boolean;
103
+ showRowHeaders?: boolean;
104
+ showRowStripes?: boolean;
105
+ mergeItems?: boolean;
106
+ };
107
+ /**
108
+ * @description Set the collapse status of the field. Those properties are used to save the collapse status of the field in the pivot table.
109
+ * @param {string} fieldId - The id of the field.
110
+ * @param {boolean} collapse - The collapse status of the field.
111
+ * @param {string} [item] - The item of the field.
112
+ */
113
+ setCollapse(fieldId: string, collapse: boolean, item?: string): void;
114
+ setFilterInfo(fieldId: string, filterInfo: IPivotTableFilterInfo): void;
115
+ getFieldFormat(fieldId: string): string | undefined;
116
+ setFieldFormat(fieldId: string, format: string | undefined): void;
117
+ setSortInfo(fieldId: string, sortInfo: IPivotTableSortInfo | undefined): void;
118
+ getSortInfo(fieldId: string): import('../types').IPivotTableLabelSortInfo | undefined;
119
+ getFilterInfo(fieldId: string): IPivotTableFilterInfo | undefined;
120
+ iterateField(callback: (field: PivotTableLabelField | PivotTableValueField) => void): void;
121
+ iterateFieldDim(callback: (field: PivotTableLabelField) => void): void;
122
+ iterateFieldMeasure(callback: (field: PivotTableValueField) => void): void;
123
+ iterateFieldByArea(area: PivotTableFiledAreaEnum, callback: (field: PivotTableLabelField | PivotTableValueField) => void): void;
124
+ /**
125
+ * @description Add a field to the pivot table.
126
+ * @param {PivotTableLabelField | PivotTableValueField} field -the field to be added.
127
+ * @param {PivotTableFiledAreaEnum} area -The area to add the field.
128
+ * @param {number} index - The index of the field in the area.
129
+ */
130
+ addField(field: PivotTableLabelField | PivotTableValueField, area: PivotTableFiledAreaEnum, index?: number): void;
131
+ /**
132
+ * @description get where the field bo be position info by field id.
133
+ * @param {string} fieldId - The id of the field.
134
+ * @typedef
135
+ * @property {PivotTableFiledAreaEnum} area - The area of the field.
136
+ * @property {number} index - The index of the field in the area.
137
+ * @returns PivotTableFiledAreaEnum
138
+ */
139
+ getFieldPositionInfoById(fieldId: string): {
140
+ area: PivotTableFiledAreaEnum | undefined;
141
+ index: number;
142
+ };
143
+ updateFieldSourceInfo(fieldId: string, sourceName: string, dataFieldId: string): void;
144
+ getFieldsAreaByType(type: PivotTableFiledAreaEnum): string[];
145
+ getFieldById(fieldId: string): PivotTableValueField | PivotTableLabelField | undefined;
146
+ isExistFieldName(fieldName: string): boolean;
147
+ /**
148
+ * @description Rename a field in the pivot table.
149
+ * @param {string} fieldId - The id of the field to be renamed.
150
+ * @param displayName - The new display name of the field.
151
+ * @returns {void}
152
+ */
153
+ renameField(fieldId: string, displayName: string): void;
154
+ /**
155
+ * @description Remove a field from the pivot table by the field id.
156
+ * @param {string} fieldId - The id of the field to be removed.
157
+ * @returns {void} -void
158
+ */
159
+ removeField(fieldId: string): void;
160
+ updateFieldPosition(fieldId: string, area: PivotTableFiledAreaEnum, index: number): void;
161
+ /**
162
+ * - Update the value position of the pivot table.
163
+ * @param valuePosition
164
+ * @param valueIndex
165
+ */
166
+ updateValuePosition(valuePosition: PivotTableValuePositionEnum, valueIndex: number): void;
167
+ /**
168
+ * - The special ΣValue fields order index in the dimension fields
169
+ * @returns {number} the index
170
+ */
171
+ getValueIndex(): number;
172
+ getValuePosition(): PivotTableValuePositionEnum;
173
+ /**
174
+ * - Whether the pivot table has the special ΣValue fields in column area.
175
+ * @returns {boolean} - has or not.
176
+ */
177
+ isColMultiMeasure(): boolean;
178
+ /**
179
+ * - Whether the pivot table has the special ΣValue fields in row area.
180
+ * @returns {boolean} - has or not.
181
+ */
182
+ isRowMultiMeasure(): boolean;
183
+ isEmpty(): boolean;
184
+ /**
185
+ * - set or update a field's subtotal type. , the table field must in the value area.
186
+ * @param {string} tableFieldId - The id of the pivot table field.
187
+ * @param {PivotSubtotalTypeEnum} subtotal - The subtotal type.
188
+ */
189
+ setSubtotalType(tableFieldId: string, subtotal: PivotSubtotalTypeEnum): void;
190
+ /**
191
+ * Represents the query data of the pivot table.Which is used to query the data from the data collection.
192
+ * @returns {IPivotTableQueryData} - The query data of the pivot table.
193
+ */
194
+ getQueryData(): IPivotTableQueryData;
195
+ fromJSON(data: IPivotTableSnapshot): void;
196
+ toJSON(): IPivotTableSnapshot;
197
+ cloneBufferModel(): PivotModel;
198
+ }
@@ -0,0 +1,224 @@
1
+ import { FieldsCollection } from '../field/fields-collection';
2
+ import { PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '../types';
3
+ import { DataField } from '../field/data-field';
4
+ import { PivotModel } from './model';
5
+ import { PivotTableLabelField, PivotTableValueField } from './table-field';
6
+ /**
7
+ * @class PivotTable - represents the wrapper class pivot table.
8
+ * @description The pivot table is a wrapper class which references the data fields collection and pivot table model.
9
+ * @implements IPivotTable
10
+ */
11
+ export declare class PivotTable {
12
+ dataFieldsCollection: FieldsCollection;
13
+ private _viewVersion;
14
+ private _model;
15
+ _bufferModel: PivotModel;
16
+ private _tupleGroupCache;
17
+ constructor(dataFieldsCollection: FieldsCollection, model?: PivotModel);
18
+ updateDataFieldsCollection(dataFieldsCollection: FieldsCollection): void;
19
+ private _getModel;
20
+ startCollectChangeset(): void;
21
+ endCollectChangeset(): import('../types').IPivotTableChangeSet[];
22
+ _generateModel(): void;
23
+ createLabelFieldByDataFieldId(dataFieldId: string, tableName?: string): PivotTableLabelField | undefined;
24
+ createValueFieldByDataFieldId(dataFieldId: string): PivotTableValueField | undefined;
25
+ updateValuePosition(valuePosition: PivotTableValuePositionEnum, valueIndex: number): void;
26
+ isColMultiMeasure(): boolean;
27
+ isRowMultiMeasure(): boolean;
28
+ /**
29
+ * get the order index of ΣValue in row or col
30
+ * @returns {number} -1 means not exist, otherwise the index of the ΣValue
31
+ */
32
+ getValueIndex(): number;
33
+ /**
34
+ * - get the value position
35
+ * @returns {PivotTableValuePositionEnum} the value position, only row or column
36
+ */
37
+ getValuePosition(): PivotTableValuePositionEnum;
38
+ /**
39
+ * - iterate all pivot table fields
40
+ * @param {(field: PivotTableLabelField | PivotTableValueField) => void} callback the callback function
41
+ */
42
+ iterateField(callback: (field: PivotTableLabelField | PivotTableValueField) => void): void;
43
+ /**
44
+ * - iterate the dimension field, it means all the label fields
45
+ * @param {(field: PivotTableLabelField | PivotTableValueField) => void} callback the callback function
46
+ */
47
+ iterateFieldDim(callback: (field: PivotTableLabelField) => void): void;
48
+ /**
49
+ * - iterate the field by the area
50
+ * @param {PivotTableFiledAreaEnum} area the area of the field enum
51
+ * @param {(field: PivotTableLabelField | PivotTableValueField) => void} callback the callback function
52
+ */
53
+ iterateFieldByArea(area: PivotTableFiledAreaEnum, callback: (field: PivotTableLabelField | PivotTableValueField) => void): void;
54
+ /**
55
+ * - get how many fields in the area
56
+ * @param {PivotTableFiledAreaEnum} area - the area of the field enum
57
+ * @returns {number} the field count
58
+ */
59
+ getFieldCountByArea(area: PivotTableFiledAreaEnum): number;
60
+ getValueFields(): string[];
61
+ /**
62
+ * - get a unique field name in the pivot table
63
+ * @param {string} autoName the given field name
64
+ * @returns {string} the unique field name
65
+ */
66
+ getUniqueValueFieldName(autoName: string): string;
67
+ /**
68
+ * - get the data field by the table field id
69
+ * @param {string} tableField - the table field id
70
+ * @returns {DataField|undefined} the data field or undefined
71
+ */
72
+ getDataFieldByTableId(tableField: string): DataField | undefined;
73
+ /**
74
+ * - get all the table fields by use the data field id
75
+ * @param dataFieldId
76
+ * @returns {string[]} the table field ids
77
+ */
78
+ getTableFieldsByDataFieldId(dataFieldId: string): (PivotTableLabelField | PivotTableValueField)[];
79
+ /**
80
+ * - get the table field by the table field id
81
+ * @param {string} tableFieldId - the table field id
82
+ * @returns {PivotTableLabelField | PivotTableValueField | undefined} the table field or undefined
83
+ */
84
+ getTableFieldById(tableFieldId: string): PivotTableLabelField | PivotTableValueField | undefined;
85
+ /**
86
+ * - check the field is exist in the pivot table or not
87
+ * @param {string} tableFieldId the check field id
88
+ * @returns {boolean} exist or not
89
+ */
90
+ isExistField(tableFieldId: string): boolean;
91
+ /**
92
+ * - get the pivot table is empty or not
93
+ * @returns {boolean} empty or not
94
+ */
95
+ isEmpty(): boolean;
96
+ /**
97
+ * - get the data field by the data field id
98
+ * @param {string} dataFieldId the data field id
99
+ * @returns {DataField|undefined} the data field or undefined
100
+ */
101
+ getDataFieldByDataFieldId(dataFieldId: string): DataField;
102
+ getDataFieldItemInfo(dataField: DataField): {
103
+ items: string[];
104
+ itemTypes: PivotDataFieldDataTypeEnum[];
105
+ };
106
+ getUniqueFieldId(): string;
107
+ /**
108
+ * - add a field to the pivot table by the source name , if the field is a measure field, it will be use auto name.
109
+ * @param {string} dataFieldId data field name
110
+ * @param {PivotTableFiledAreaEnum} area the area of the added field
111
+ * @param {number} [index] the position of the field in the area, if not set, the field will be added to the end of the area.
112
+ * @returns {PivotTableLabelField|PivotTableValueField} the added field
113
+ */
114
+ addFieldWithSourceId(dataFieldId: string, area: PivotTableFiledAreaEnum, index?: number): PivotTableValueField | PivotTableLabelField | undefined;
115
+ setOptions(options: IPivotTableOptions): void;
116
+ /**
117
+ * the func is only use for when refresh
118
+ * @param {string} fieldId the table field id
119
+ * @param {string} sourceName the source name of the field
120
+ * @param {string} dataFieldId the data field id
121
+ */
122
+ updateFieldSourceInfo(fieldId: string, sourceName: string, dataFieldId: string): void;
123
+ /**
124
+ * - Set the subtotal type of the field. only the value field can set the subtotal type. only effective for the value field.
125
+ * @param {string} fieldId - The id of the field.
126
+ * @param {PivotSubtotalTypeEnum} subtotalType - The subtotal type of the field.
127
+ */
128
+ setSubtotalType(fieldId: string, subtotalType: PivotSubtotalTypeEnum): void;
129
+ /**
130
+ * - Rename the field.
131
+ * @param {string} fieldId - The id of the field.
132
+ * @param {string} displayName - The display name of the field.
133
+ */
134
+ renameField(fieldId: string, displayName: string): void;
135
+ /**
136
+ * - Set the filter information of the dimension field. only the dimension field can set the filter information.
137
+ * @param fieldId
138
+ * @param filterInfo
139
+ */
140
+ setFilterInfo(fieldId: string, filterInfo: IPivotTableFilterInfo): void;
141
+ /**
142
+ * - Set the sort information of the dimension field. only the dimension field can set the sort information.
143
+ * @param {string} fieldId - The id of the field.
144
+ * @param {IPivotTableSortInfo} sortInfo - The sort information of the field.
145
+ */
146
+ setSortInfo(fieldId: string, sortInfo: IPivotTableSortInfo | undefined): void;
147
+ /**
148
+ * - get the sort information of the dimension field.
149
+ * @param fieldId - The id of the field.
150
+ * @returns {IPivotTableSortInfo} -The sort information of the field.
151
+ */
152
+ getSortInfo(fieldId: string): import('../types').IPivotTableLabelSortInfo | undefined;
153
+ getFilterInfo(fieldId: string): IPivotTableFilterInfo | undefined;
154
+ /**
155
+ * get the filter information by the filter index
156
+ * @param {number} index - The index of the filter field.
157
+ * @returns {string | undefined} the table field id
158
+ */
159
+ getFilterFieldIdByIndex(index: number): string;
160
+ /**
161
+ * - set the position of the field in the pivot table. which used in pivot panel drag field.
162
+ * @param {string} fieldId - The id of the pivot table field.
163
+ * @param {PivotTableFiledAreaEnum} area which area the field will be placed.
164
+ * @param {number} index the index of the field in the area.
165
+ */
166
+ updateFieldPosition(fieldId: string, area: PivotTableFiledAreaEnum, index: number): void;
167
+ /**
168
+ * - get a format for pivot table field, which will be applied in the pivot table view. the label field will use the format to format the date value.
169
+ * @description when a show data as type is selected, we should set the format for the field.
170
+ * @param {string} fieldId -the field id
171
+ * @returns {string} the field format code
172
+ */
173
+ getFieldFormat(fieldId: string): string | undefined;
174
+ /**
175
+ * - set the format for pivot table field, which will be applied in the pivot table view. the label field will use the format to format the date value.
176
+ * @description when a show data as type is selected, we should set the format for the field. a label field which contains the date value should set the format.
177
+ * @param {string} fieldId
178
+ * @param {string|undefined} format
179
+ */
180
+ setFieldFormat(fieldId: string, format: string | undefined): void;
181
+ /**
182
+ *
183
+ * @param field
184
+ * @param area
185
+ * @example
186
+ * const pt= new PivotTable(fieldsCollection);
187
+ * var areaField = pt.addFieldWithSourceName('区域', PivotTableFiledAreaEnum.Column);
188
+ * pt.addFieldWithSourceName('省份', PivotTableFiledAreaEnum.Filter);
189
+ */
190
+ addField(field: PivotTableLabelField | PivotTableValueField, area: PivotTableFiledAreaEnum, index?: number): void;
191
+ removeField(fieldId: string): void;
192
+ getOptions(): {
193
+ pageWrap?: number;
194
+ pageOverThenDown?: boolean;
195
+ showColHeaders?: boolean;
196
+ showColStripes?: boolean;
197
+ showLastColumn?: boolean;
198
+ showRowHeaders?: boolean;
199
+ showRowStripes?: boolean;
200
+ mergeItems?: boolean;
201
+ };
202
+ /**
203
+ * @description Set the collapse status of the field. Those properties are used to save the collapse status of the field in the pivot table.
204
+ * @param {string} fieldId - The id of the field.
205
+ * @param {boolean} collapse - The collapse status of the field.
206
+ * @param {string} [item] - The item of the field.
207
+ */
208
+ setCollapse(fieldId: string, collapse: boolean, item?: string): void;
209
+ /**
210
+ * - get the pivot view need query or not
211
+ * @param {number} viewVersion
212
+ * @returns {boolean} - need query or not
213
+ */
214
+ getNeedQuery(viewVersion: number): boolean;
215
+ getFieldPositionInfoById(fieldId: string): {
216
+ area: PivotTableFiledAreaEnum | undefined;
217
+ index: number;
218
+ };
219
+ private _getTupleCache;
220
+ query(config?: IPivotTableQueryData): import('..').PivotView;
221
+ toJSON(): IPivotTableSnapshot;
222
+ fromJSON(data: IPivotTableSnapshot): void;
223
+ dispose(): void;
224
+ }