UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

127 lines 4.43 kB
export declare type Collection = Array<{ [key: string]: any; }>; declare type Fields = string[] | string; /** * stackByFields * * D3's `stack` groups each series' data together but we sometimes we want the * stacked groups to remain grouped as in the original normalized data. This * function helps achieve that. * * @param {object[]} collection - normalized data you want to operate on * @param {string[]} fields - fields to pluck off for the y data * @return {array[]} - array of arrays, one for row in the original `collection` */ export declare function stackByFields(collection: Collection, fields: Fields): Array<Array<[number, number]>>; /** * extractFields * * This will return the data in a similar format to stackByFields but without * the stacking. * * @param {object[]} collection - normalized data you want to operate on * @param {string[]} fields - fields to pluck off for the y data * @return {array[]} - array of arrays, one for each field */ export declare function extractFields(collection: Collection, fields: Fields, minDomainValue?: number): Array<Array<[number, number]>>; /** * groupByFields * * This will return the data in a similar format to d3Shape.stack * but without the stacking of the data. * * @param {object[]} collection - normalized data you want to operate on * @param {string[]} fields - fields to pluck off for the y data * @return {array[]} - array of arrays, one for each field */ export declare function groupByFields(collection: Collection, fields: Fields): any[][]; /** * byFields * * Takes a collection of data and returns an array of all the fields off that * collection. * * @param {object[]} collection * @param {string[]} fields * @return {array} */ export declare function byFields(collection: Collection, fields: Fields): object[]; /** * nearest * * Divide and conquer algorithm that helps find the nearest element to `value` * in `nums` * * @param {number[]} nums - sorted array of numbers to search through * @param {number} value - value you're trying to locate the nearest array element for * @return {number} - the nearest array element to the value */ export declare function nearest(nums: number[], value: number): number | undefined; /** * minByFields * * Returns the minimum element from a collection by a set of fields. * * @param {object[]} collection * @param {string[]} fields * @return {any} */ export declare function minByFields(collection: Collection, fields: Fields): object | undefined; /** * maxByFields * * Returns the maximum element from a collection by a set of fields. * * @param {object[]} collection * @param {string[]} fields * @return {any} */ export declare function maxByFields(collection: Collection, fields: Fields): object | undefined; /** * maxByFieldsStacked * * Returns the max sum of a set of fields from a collection * * @param {object[]} collection * @param {string[]} fields * @return {any} */ export declare function maxByFieldsStacked(collection: Collection, fields: Fields): number | undefined; /** * discreteTicks * * Returns `count` evenly spaced, representative values from the `array`. * * @param {array} array * @param {number} size - should be greater than 1 * @return {array} */ export declare function discreteTicks<T>(array: T[], count?: number | undefined | null): T[]; /** * transformFromCenter * * Scaling paths from their center is tricky. This function * helps do that be generating a translate/scale transform * string with the correct numbers. * * @param {number} x - the x data point where you want the path to be centered at * @param {number} y - the y data point where you want the path to be centered at * @param {number} xCenter - the x coordinate of the center of the path you're trying to transform * @param {number} yCenter - the x coordinate of the center of the path you're trying to transform * @param {number} scale - number to scale to, 2 would be 2x bigger * @return {string} - transform string */ export declare function transformFromCenter(x: number, y: number, xCenter: number, yCenter: number, scale: number): string; /** * formatDate * * This function was written to be used for tick formatting with d3 time * scales. * * @param {date} date - input date * @return {string} - formatted date */ export declare function formatDate(date: Date): string; export {}; //# sourceMappingURL=chart-helpers.d.ts.map