parallel.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.parallel = void 0;
  4. /* eslint-disable @typescript-eslint/no-unused-vars */
  5. var scale_1 = require("@antv/scale");
  6. /**
  7. * Apples parallel coordinate transform.
  8. * @param params [x0, x1, y0, y1]
  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. */
  15. var parallel = function (params, x, y, width, height) {
  16. var _a = params, x0 = _a[0], x1 = _a[1], y0 = _a[2], y1 = _a[3];
  17. var sy = new scale_1.Linear({
  18. range: [y0, y1],
  19. });
  20. return {
  21. transform: function (vector) {
  22. var v = [];
  23. var len = vector.length;
  24. var sx = new scale_1.Point({
  25. domain: new Array(len).fill(0).map(function (_, i) { return i; }),
  26. range: [x0, x1],
  27. });
  28. for (var i = 0; i < len; i++) {
  29. var e = vector[i];
  30. var x_1 = sx.map(i);
  31. var y_1 = sy.map(e);
  32. v.push(x_1, y_1);
  33. }
  34. return v;
  35. },
  36. untransform: function (vector) {
  37. var v = [];
  38. for (var i = 0; i < vector.length; i += 2) {
  39. var y_2 = vector[i + 1];
  40. v.push(sy.invert(y_2));
  41. }
  42. return v;
  43. },
  44. };
  45. };
  46. exports.parallel = parallel;
  47. //# sourceMappingURL=parallel.js.map