pyramid.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Pyramid = void 0;
  4. const coordinate_1 = require("../../utils/coordinate");
  5. const funnel_1 = require("./funnel");
  6. /**
  7. * Adjust and return the new `points`.
  8. */
  9. function getPyramidPoints(points, nextPoints, coordinate) {
  10. const [p0, p1, p2, p3] = points;
  11. if ((0, coordinate_1.isTranspose)(coordinate)) {
  12. const newP1 = [
  13. nextPoints ? nextPoints[0][0] : (p1[0] + p2[0]) / 2,
  14. p1[1],
  15. ];
  16. const newP2 = [
  17. nextPoints ? nextPoints[3][0] : (p1[0] + p2[0]) / 2,
  18. p2[1],
  19. ];
  20. return [p0, newP1, newP2, p3];
  21. }
  22. const newP1 = [
  23. p1[0],
  24. nextPoints ? nextPoints[0][1] : (p1[1] + p2[1]) / 2,
  25. ];
  26. const newP2 = [
  27. p2[0],
  28. nextPoints ? nextPoints[3][1] : (p1[1] + p2[1]) / 2,
  29. ];
  30. return [p0, newP1, newP2, p3];
  31. }
  32. /**
  33. * Render pyramid in different coordinate and using color channel for stroke and fill attribute.
  34. */
  35. const Pyramid = (options) => {
  36. return (0, funnel_1.Funnel)(Object.assign({ adjustPoints: getPyramidPoints }, options));
  37. };
  38. exports.Pyramid = Pyramid;
  39. exports.Pyramid.props = {
  40. defaultMarker: 'square',
  41. };
  42. //# sourceMappingURL=pyramid.js.map