@univerjs-pro/engine-pivot
Version:
Pivot table calculation engine for Univer Pro.
133 lines (132 loc) • 6.02 kB
TypeScript
import type { IPivotTableFilterInfo, IPivotTableLabelFieldJSON, IPivotTableLabelFieldQueryData, IPivotTableShowDataAsInfo, IPivotTableSortInfo, IPivotTableValueFieldJSON, IPivotTableValueFieldQueryData } from '../types';
import { PivotSubtotalTypeEnum } from '../types';
/**
* Represents a base class for the field in a pivot table.
* @abstract
* @description The base class for the field in a pivot table.
* @property {string} dataFieldId - The base data field id of the field.
* @property {string} id - The unique identifier of the field.
* @property {string} displayName - The display name of the field. the default value is the data field name.
* @property {string} lossLessProperty - thr public object to save the property not defined but should be saved.
*
*/
export declare abstract class PivotTableFieldBase {
/**
* @property {string} - The base data field id of the field.
*/
readonly dataFieldId: string;
readonly id: string;
readonly sourceName: string;
displayName: string;
format: string | undefined;
lossLessProperty?: any;
constructor(dataFieldId: string, id: string, displayName: string | undefined, sourceName: string);
getId(): string;
/**
* - the read only name in collection
* @returns {string} - the source name of the field, which is the name of the data field.
*/
getSourceName(): string;
setSourceName(sourceName: string): void;
setDataFieldId(dataFieldId: string): void;
getDataFieldId(): string;
getFormat(): string | undefined;
setFormat(format: string | undefined): void;
setDisplayName(displayName: string): void;
getDisplayName(): string;
/**
* @abstract
*/
abstract toJSON(): object;
/**
* @abstract
* @param {object} data - the data config a field.
*/
abstract fromJSON(data: object): void;
/**
* @abstract
* @returns {object} - the query data of the field.
*/
abstract getQueryData(): object;
}
export declare class PivotTableValueField extends PivotTableFieldBase {
subtotal: PivotSubtotalTypeEnum;
showDataAs: IPivotTableShowDataAsInfo;
constructor(dataFieldId: string, id: string, displayName: string | undefined, sourceName: string);
setSubtotal(subtotal: PivotSubtotalTypeEnum): void;
getSubtotal(): PivotSubtotalTypeEnum;
setShowDataAs(showDataAs: IPivotTableShowDataAsInfo): void;
getShowDataAs(): IPivotTableShowDataAsInfo;
getQueryData(): IPivotTableValueFieldQueryData;
/**
* @override
* @returns {IPivotTableValueFieldJSON} - the JSON data of the value field.
*/
toJSON(): IPivotTableValueFieldJSON;
/**
* @override
* @param data
*/
fromJSON(data: IPivotTableValueFieldJSON): void;
}
/**
* Represents a label field in a pivot table.
*/
export declare class PivotTableLabelField extends PivotTableFieldBase {
sortInfo: IPivotTableSortInfo | undefined;
filterInfo: IPivotTableFilterInfo;
constructor(dataFieldId: string, id: string, displayName: string | undefined, sourceName: string);
/**
* @method setSortInfo
* @description Set the sort information of the label field.
* @param {IPivotTableSortInfo} sortInfo - The sort information of the label field.
*/
setSortInfo(sortInfo: IPivotTableSortInfo | undefined): void;
/**
* @method getSortInfo
* @description Get the sort information of the label field.
* @returns {IPivotTableSortInfo} The sort information of the label field.
*/
getSortInfo(): IPivotTableSortInfo | undefined;
/**
* @method setFilterInfo
* @description Set the filter information of the label field. Only one of the manual filter, custom filter or value filter can be effective.
* @param {IPivotTableFilterInfo} filterInfo - The filter information of the label field. the manual filter, custom filter or value filter is opposite to each other.
*/
setFilterInfo(filterInfo: IPivotTableFilterInfo): void;
/**
* @method getFilterInfo
* @description Get the filter information of the label field.
* @returns {IPivotTableFilterInfo} The filter information of the label field.
*/
getFilterInfo(): IPivotTableFilterInfo;
getQueryData(): IPivotTableLabelFieldQueryData;
toJSON(): IPivotTableLabelFieldJSON;
fromJSON(data: IPivotTableLabelFieldJSON): void;
}
/**
* Clone the label field to a value field.
* @param {PivotTableLabelField} labelField - The label field to be cloned.
* @param {boolean} [keepUnknown] - Whether to keep the unknown property of the label field. the default value is true.
* @returns {PivotTableValueField} - the value field may has sortInfo and filterInfo in the property lossLessProperty.
*/
export declare function cloneLabelFieldToValueField(labelField: PivotTableLabelField, keepUnknown?: boolean): PivotTableValueField;
/**
* Clone the value field to a label field.
* @param {PivotTableValueField} valueField - The value field to be cloned.
* @param {boolean} [keepUnknown] - Whether to keep the unknown property of the value field. the default value is true.
* @returns {PivotTableLabelField} - the label field may has sortInfo and filterInfo in the property lossLessProperty.
*/
export declare function cloneValueFieldToLabelField(valueField: PivotTableValueField, keepUnknown?: boolean): PivotTableLabelField;
/**
* - Create a value field from the JSON data.
* @param {IPivotTableValueFieldJSON} data - The JSON data of the value field.
* @returns {PivotTableValueField} - The value field created from the JSON data.
*/
export declare function createValueField(data: IPivotTableValueFieldJSON): PivotTableValueField;
/**
* - Create a label field from the JSON data.
* @param {IPivotTableLabelFieldJSON} data - The JSON data of the label field.
* @returns {PivotTableLabelField} - The label field created from the JSON data.
*/
export declare function createLabelField(data: IPivotTableLabelFieldJSON): PivotTableLabelField;