UNPKG

@adyen/lume-vue3

Version:

Lume is a Vue data visualization component library, built with Typescript and D3.

112 lines 4.48 kB
import { Ref, Slots } from 'vue'; import { ScaleBand } from 'd3'; import { Data, DatasetValueObject, InternalData } from '@/types/dataset'; import { Scale } from '@/composables/scales'; export declare function isProd(): boolean; /** * Returns an array with all numeric values present in a chart's `data` (array of datasets). * @param {Data<DatasetValueObject>} data A computed array of datasets. * @returns {Array<number>} An array of all numeric values. */ export declare function flatValues(data: InternalData): Array<number>; /** * Checks if provided data has only 1 dataset. * @param {Data} data The data prop * @returns {boolean} True if valid single dataset data */ export declare function singleDatasetValidator(data: Data): boolean; /** * Checks if provided data is valid for a chart legend. * @param {InternalData} data The data prop. * @returns {boolean} True if valid data. */ export declare function dataValidator(data: InternalData): boolean; /** * Checks if provided item is an object. * @param {unknown} item * @returns {boolean} True if item is an object. */ export declare function isObject(item: unknown): item is Record<string, unknown>; /** * Deep merge n objects. * Clones both target and sources so that they don't get mutated. * * @param {Record<string, unknown>} target Object to merge to. * @param {Array<Record<string, unknown>>} source Object(s) to merge into target. */ export declare function mergeDeep(target: Record<string, unknown>, source: Record<string, unknown>): { [x: string]: unknown; }; /** * Checks if provided item is a DatasetValueObject. * @param {unknown} object * @returns {boolean} True if item is a DatasetValueObject. */ export declare function isDatasetValueObject(object: unknown): object is DatasetValueObject; export declare function isBandScale(scale: Scale): scale is ScaleBand<string | number>; export declare function getScaleStep(scale: Scale): number; export declare function isScaleEmpty(scale: Scale): boolean; /** * Returns the highest value of all provided datasets in a given index. * * @param {Data} data The data to use. * @param {number} index THe index to check for. * @returns {number} The highest value. */ export declare function getHighestValue(data: InternalData, index: number): number; /** * Returns an empty array with length equal to that of the dataset. * * @param data A data group. * @returns An empty array. */ export declare function getEmptyArrayFromData(data: (Data | InternalData) | Ref<Data | InternalData>): any[]; /** * Returns the length of a scale domain. * * @param scale The scale to get the length from. * @returns The domain length. */ export declare function getDomainLength(scale: Scale): number; /** * Generates an interpolator from `start` to `end`, this is equivalent to d3-interpolate interpolateRound function. * @param start {number} * @param end {number} */ export declare function interpolateRound(start: number, end: number): (t: number) => number; /** * Shifts all items in an array N number of indexes. * Default direction is to the left (e.g [1, 2, 3] -> [2, 3, 1]) * @param array An array to shift. * @param amount N number of indexes to move. * @param toRight If true, moves items to the right instead. * @returns A same length array with its items moved. */ export declare function shiftItems(array: Array<unknown>, amount: number, toRight?: boolean): unknown[]; /** * @param slots * @returns all slots except the groups */ export declare function excludeGroups(slots: Slots): any; /** * @param slots * @returns all slots except the ones present in LumeChart */ export declare function excludeChartSlots(slots: Slots): any; /** * Generates a random string. * https://github.com/ai/nanoid/blob/main/nanoid.js * * @param t String length. * @returns Random string of characters. */ export declare const nanoid: (n?: number) => string; /** * Fills the rest of the array with null values if the input array is less than the passed length * @param inputArray The array to be processed * @param minimumOutputArrayLength Minimum length of the returned array * @returns If the input array length is lesser than the passed minimum length, then fills the reminder with null values * Otherwise returns the input array as it is. */ export declare function fillArrayWithNullValues(inputArray: Array<number | DatasetValueObject>, minimumOutputArrayLength: number): any[]; //# sourceMappingURL=helpers.d.ts.map