@mindfiredigital/pivothead
Version:
PivotHead is a powerful and flexible library for creating interactive pivot tables in JavaScript applications. It provides a core engine for data manipulation and, in the future, will be compatible with wrappers for React, Vue, Svelte, and Angular, making
149 lines • 3.74 kB
TypeScript
export interface AxisConfig {
uniqueName: string;
caption?: string;
sortOrder?: 'asc' | 'desc';
}
export interface DataSourceConfig {
type: 'local' | 'remote' | 'file';
url?: string;
file?: File;
}
export interface Column {
field: string;
label: string;
type?: 'string' | 'number' | 'date';
}
export interface SortConfig {
field: string;
direction: 'asc' | 'desc';
type?: 'measure' | 'dimension';
aggregation?: AggregationType;
}
export interface RowSize {
index: number;
height: number;
}
export interface ExpandedState {
[key: string]: boolean;
}
export interface GroupConfig {
rowFields: string[];
columnFields: string[];
grouper: (item: any, fields: string[]) => string;
}
export interface Group {
key: string;
items: any[];
subgroups?: Group[];
aggregates: {
[key: string]: number;
};
level?: number;
}
export interface FormatOptions {
type: 'currency' | 'number' | 'percentage' | 'date';
locale?: string;
currency?: string;
decimals?: number;
dateFormat?: string;
}
export type AggregationType = 'sum' | 'avg' | 'count' | 'min' | 'max';
export interface Measure {
field: string;
label: string;
type: 'number';
format?: FormatOptions;
aggregation?: AggregationType;
}
export interface Dimension {
field: string;
label: string;
type: 'string' | 'date';
format?: FormatOptions;
}
export interface FilterConfig {
field: string;
operator: 'equals' | 'contains' | 'greaterThan' | 'lessThan' | 'between';
value: any;
}
export interface PaginationConfig {
currentPage: number;
pageSize: number;
totalPages: number;
}
export interface PivotTableState<T> {
data: T[];
processedData: ProcessedData;
sortConfig: SortConfig[];
rows: AxisConfig[];
columns: AxisConfig[];
measures: MeasureConfig[];
rowSizes: RowSize[];
expandedRows: ExpandedState;
groupConfig: GroupConfig | null;
groups: Group[];
selectedMeasures: MeasureConfig[];
selectedDimensions: Dimension[];
selectedAggregation: AggregationType;
formatting: {
[key: string]: FormatOptions;
};
columnWidths: {
[key: string]: number;
};
isResponsive: boolean;
rowGroups: Group[];
columnGroups: Group[];
filterConfig: FilterConfig[];
paginationConfig: PaginationConfig;
}
export interface PivotTableConfig<T> {
data: T[];
dataSource?: DataSourceConfig;
rows: AxisConfig[];
columns: AxisConfig[];
measures: MeasureConfig[];
dimensions: Dimension[];
groupConfig?: GroupConfig | null;
formatting?: {
[key: string]: FormatOptions;
};
defaultAggregation: AggregationType;
isResponsive?: boolean;
initialSort?: SortConfig[];
pageSize?: number;
onRowDragEnd?: (fromIndex: number, toIndex: number, newData: T[]) => void;
onColumnDragEnd?: (fromIndex: number, toIndex: number, newColumns: {
uniqueName: string;
caption: string;
}[]) => void;
}
export interface MeasureConfig {
uniqueName: string;
caption?: string;
aggregation: AggregationType;
format?: FormatOptions;
formula?: (item: any) => number;
sortabled?: boolean;
}
export interface ProcessedData {
headers: string[];
rows: any[][];
totals: Record<string, number>;
}
export interface ProcessedDataResult<T> {
data: T[];
groups: Group[];
}
export type ChartType = 'bar' | 'line' | 'pie' | 'scatter';
export interface PivotData {
[key: string]: string | number;
}
export type Row = {
[key: string]: any;
};
export type Config = {
columns: Column[];
data: Row[];
};
//# sourceMappingURL=interfaces.d.ts.map