reaviz
Version:
Data Visualization using React
73 lines (72 loc) • 2.46 kB
TypeScript
type PointObjectNotation = {
x: number;
y: number;
};
/**
* Get the data point closest to a given position on a continuous scale.
*
* @param {Object} params - The parameters for the function.
* @param {number} params.pos - The position to find the closest point to.
* @param {Object} params.scale - The scale object.
* @param {Array} params.data - The data array.
* @param {string} [params.attr='x'] - The attribute to use for comparison.
* @param {boolean} [params.roundDown=false] - Whether to round down to the nearest point.
*
* @returns {Object} The closest point to the specified position.
*/
export declare const getClosestContinousScalePoint: ({ pos, scale, data, attr, roundDown }: {
pos: number;
scale: any;
data: any[];
attr?: string;
roundDown?: boolean;
}) => any;
/**
* Get the data point closest to a given position on a band scale. This rounds down by default.
*
* @param {Object} params - The parameters for the function.
* @param {number} params.pos - The position to find the closest point to.
* @param {Object} params.scale - The scale object.
* @param {Array} params.data - The data array.
* @param {boolean} [params.roundClosest=false] - Whether to round to the closest point instead of down.
*
* @returns {Object} The closest point to the specified position.
*/
export declare const getClosestBandScalePoint: ({ pos, scale, data, roundClosest }: {
pos: number;
scale: any;
data: any[];
roundClosest?: boolean;
}) => any;
/**
* Given an event, get the parent svg element;
*/
export declare const getParentSVG: (event: any) => any;
/**
* Given an event, get the relative X/Y position for a target.
*/
export declare const getPositionForTarget: ({ target, clientX, clientY }: {
target: any;
clientX: any;
clientY: any;
}) => {
x: number;
y: number;
};
/**
* Gets the point from q given matrix.
*/
export declare const getPointFromMatrix: (event: any, matrix: any) => PointObjectNotation;
/**
* Get the start/end matrix.
*/
export declare const getLimitMatrix: (height: number, width: number, matrix: any) => PointObjectNotation[];
/**
* Constrain the matrix.
*/
export declare const constrainMatrix: (height: number, width: number, matrix: any) => boolean;
/**
* Determine if both min and max scale fctors are going out of bounds.
*/
export declare const isZoomLevelGoingOutOfBounds: (value: any, scaleFactor: number) => boolean;
export {};