UNPKG

1.13 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.cartesian = void 0;
4/* eslint-disable @typescript-eslint/no-unused-vars */
5var scale_1 = require("@antv/scale");
6/**
7 * Maps normalized value to the bounding box of coordinate.
8 * @param params []
9 * @param x x of the the bounding box of coordinate
10 * @param y y of the the bounding box of coordinate
11 * @param width width of the the bounding box of coordinate
12 * @param height height of the the bounding box of coordinate
13 * @returns transformer
14 */
15var cartesian = function (params, x, y, width, height) {
16 var sx = new scale_1.Linear({
17 range: [x, x + width],
18 });
19 var sy = new scale_1.Linear({
20 range: [y, y + height],
21 });
22 return {
23 transform: function (vector) {
24 var v1 = vector[0], v2 = vector[1];
25 return [sx.map(v1), sy.map(v2)];
26 },
27 untransform: function (vector) {
28 var v1 = vector[0], v2 = vector[1];
29 return [sx.invert(v1), sy.invert(v2)];
30 },
31 };
32};
33exports.cartesian = cartesian;
34//# sourceMappingURL=cartesian.js.map
\No newline at end of file