UNPKG

@antv/t8

Version:

T8 is a text visualization solution for unstructured data within the AntV technology stack, and it is a declarative JSON Schema syntax that can be used to describe the content of data interpretation reports.

21 lines (19 loc) 698 B
/** * Creates a linear scale function that maps values from domain to range * * @param domain - Input range [min, max] of values to be scaled * @param range - Output range [min, max] that domain values will be mapped to * @returns A function that performs the linear scaling transformation */ var scaleLinear = function (domain, range) { return function (n) { var d1 = domain[0], d2 = domain[1]; var r1 = range[0], r2 = range[1]; // Returns the intermediate value when the range is zero. if (r1 === r2) return (d2 - d1) / 2; return (n / (r2 - r1)) * (d2 - d1); }; }; export { scaleLinear }; //# sourceMappingURL=scaleLinear.js.map