@sheetxl/models
Version:
Models - A Headless javascript spreadsheet library.
75 lines • 2.53 kB
TypeScript
/**
* Adapted from https://medium.com/@sahirnambiar/linear-least-squares-a-javascript-implementation-and-a-definitional-question-e3fba55a6d4b
*/
export declare const leastSquaresSlopeAndIntercept: (values: number[]) => {
m: number;
b: number;
};
/**
* return the value for the given trend.
* Note - The value can be negative or positive but will never be 0.
*/
export type TrendForecast = (xOffset: number) => any;
/**
* Interface used for generating trends
*/
export interface TrendType {
/**
* called with the value to see if the value is this type.
* @return null if the value is not of this type.
*/
getKey(value: any): string | null;
/**
* This will be called for all values that are found
* in a set that have the same return from getType.
*/
createTrend: (yValues: any[], key: string, blankInterval: number | null, totalCount: number) => TrendForecast;
}
export interface AutoFiller<T> {
/**
* Returns an array of values filled to the amount
* * If a positive value is used this will will show forecasted points after the set provided.
* * If a negative value is use this will forecast before.
*
* Note - This will return null if the values are : null, empty, or an array with null values.
*
* @param amount
*/
fillTo(amount: number): T[];
/**
* Similar to @see {@link fillTo} extend it only fills a single point. This is useful for preview
* @param amount
*/
fillAt(amount: number): T;
}
/**
* The options for autoFill. @see {@link AutoFill}
*/
export interface AutoFillOptions {
/**
* TODO - implement
*/
stepValue?: number;
/**
* TODO - implement
*/
stopValue?: number;
/**
* Provide the options to override trend types
* @defaultValue DEFAULT_TREND_TYPES
*/
trendTypes?: readonly TrendType[];
}
/**
* Returns a list of values that fit the patten provided.
*
* @param values the values that will be used to determine the pattern for extending
* @param options see @AutoFillOptions
* If a positive value is used this will will show forecasted points after the set provided.
* If a negative value is use this will forecast before.
*
* Note - This will return null if the values are : null, empty, or an array with null values.
*/
export declare const autoFill: (values: any[], options?: AutoFillOptions) => AutoFiller<any>;
export declare const constantAutoFill: (value: any) => AutoFiller<any>;
//# sourceMappingURL=AutoFill.d.ts.map