import type { BarChartOptionsBase } from "../mod.js"; import type { Labels } from "../types.js"; /** * Utility function to calculate an automatic gap size between items based on the length of the surface and the number of items. * @param surfaceLength - length of the surface the items are being placed on (e.g. width of a bar chart) * @param numItems - number of items being placed on the surface (e.g. number of bars in a bar chart) * @returns calculated gap size between items, which is 1/4 of the average space allocated for each item on the surface */ export declare const autoGap: (surfaceLength: number, numItems: number) => number; /** * Utility function to calculate the percentage of a number relative to another number. * @param num - decimal number * @param ofnum - number to calculate the percentage of * @returns percentage value */ export declare const asPercent: (num: number, ofnum: number) => number; /** * Utility function to round a number to the nearest target, with optional direction to round up or down. * @param n - number to be rounded * @param t - target to round to * @param upDown - direction to round ("up" or "down") * @returns rounded number */ export declare const roundTo: (n: number, t?: number, upDown?: "up" | "down") => number; /** * Utility function to round a number to the nearest 10th, **up or down** * @param n - number to round to nearest 10 * @returns number rounded to nearest 10 */ export declare const roundToTen: (n: number) => number; /** * Utility function to round a number **up** to the nearest 10th * @param n - number to round up * @returns number rounded up to nearest 10th */ export declare const roundUpToTen: (n: number) => number; /** * Utility function to round a number **up** to the nearest 100th * @param n - number to round up * @returns number rounded up to nearest 100th */ export declare const roundUpTo100: (n: number) => number; /** * Simple distance formula implementation * @param x1 * @param y1 * @param x2 * @param y2 * @returns resulting distance between two given points */ export declare const distTwoPoint: (x1: number, y1: number, x2: number, y2: number) => number; /** * Simple midpoint formula implementation * @param x1 * @param y1 * @param x2 * @param y2 * @returns midpoint coordinates between two given points */ export declare const midpoint: (x1: number, y1: number, x2: number, y2: number) => [number, number]; /** * A utility function to get a single item from an array or just return the item if it's not an array. If it's an array, it wraps around using the index and modulo. * * This is useful for options that are meant to wrap around, but for users can also just be a single value, allowing for easy supporting of alternating values & single values. * * Example: * ```ts * getOnlyItemOrWrap("red", 0) // "red" * getOnlyItemOrWrap(["red", "blue"], 0) // "red" * getOnlyItemOrWrap(["red", "blue"], 1) // "blue" * getOnlyItemOrWrap(["red", "blue"], 2) // "red" * ``` * * --- * * @param v - Arraylike or single item value * @param i - Index being grabbed from the value (if arraylike) * @returns - A single item, either from the array wrapping around or if it's just one thing then that's given back */ export declare const getOnlyItemOrWrap: (v: T | T[], i: number) => T; /** * This utility function is currently used by both pie & donut charts. It sums the previous angle radians for a given index, used in the calculations for slice centroids. */ export declare const sumPrevAngleRads: (i: number, asCoords: [number, number, number][], asPercentages: number[], totalLength: number, radius: number) => number; /** * Creates datalabel text based on datalabel choice * @param datalabelChoice - The type of data label to generate, either "literal" for the actual data point value or "percentage" for the percentage representation of the data point relative to the sum of all data points. * @param dataPoint - The individual data point value for which the label text is being generated. * @param sum - Sum of all data points * @returns The generated data label text */ export declare const getDataLabelText: (datalabelChoice: Labels["dataLabels"], dataPoint: number, sum: number) => string; /** * Calculates the x and y offsets for image labels based on the specified placement of bars in a chart. * The offsets shift the image labels slightly away from the bars to avoid overlap. * @param placement - The placement of bars in the chart, which can be "top", "bottom", "left", or "right". * @returns A tuple containing the x and y offsets for image labels based on the specified placement. */ export declare const calcImageLabelOffset: (placement: BarChartOptionsBase["placement"]) => readonly [0 | 15 | -15, 0 | 15 | -15]; export declare const classNames: { readonly labelTextEle: "jgmc-text"; readonly imageLabelGroupEle: "jgmc-image-label-group"; readonly imageLabelEle: "jgmc-image-label"; readonly centerLabelEle: "jgmc-center-label"; readonly rectEle: "jgmc-rect"; readonly groupEle: "jgmc-group"; readonly svgEle: "jgmc-svg"; readonly pathEle: "jgmc-path"; }; //# sourceMappingURL=common.d.ts.map