cartesian.js 980 B

123456789101112131415161718192021222324252627282930
  1. /* eslint-disable @typescript-eslint/no-unused-vars */
  2. import { Linear } from '@antv/scale';
  3. /**
  4. * Maps normalized value to the bounding box of coordinate.
  5. * @param params []
  6. * @param x x of the the bounding box of coordinate
  7. * @param y y of the the bounding box of coordinate
  8. * @param width width of the the bounding box of coordinate
  9. * @param height height of the the bounding box of coordinate
  10. * @returns transformer
  11. */
  12. export var cartesian = function (params, x, y, width, height) {
  13. var sx = new Linear({
  14. range: [x, x + width],
  15. });
  16. var sy = new Linear({
  17. range: [y, y + height],
  18. });
  19. return {
  20. transform: function (vector) {
  21. var v1 = vector[0], v2 = vector[1];
  22. return [sx.map(v1), sy.map(v2)];
  23. },
  24. untransform: function (vector) {
  25. var v1 = vector[0], v2 = vector[1];
  26. return [sx.invert(v1), sy.invert(v2)];
  27. },
  28. };
  29. };
  30. //# sourceMappingURL=cartesian.js.map