helper.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.getClip = getClip;
  4. exports.isPointInPlot = isPointInPlot;
  5. var _index = require("../graphic/index");
  6. function getClip(coord) {
  7. var start = coord.start;
  8. var end = coord.end;
  9. var width = end.x - start.x;
  10. var height = Math.abs(end.y - start.y);
  11. var margin = 10;
  12. var clip;
  13. if (coord.isPolar) {
  14. var circleRadius = coord.circleRadius,
  15. center = coord.center,
  16. startAngle = coord.startAngle,
  17. endAngle = coord.endAngle;
  18. clip = new _index.Shape.Sector({
  19. attrs: {
  20. x: center.x,
  21. y: center.y,
  22. r: circleRadius,
  23. r0: 0,
  24. startAngle: startAngle,
  25. endAngle: endAngle
  26. }
  27. });
  28. } else {
  29. clip = new _index.Shape.Rect({
  30. attrs: {
  31. x: start.x,
  32. y: end.y - margin,
  33. width: width,
  34. height: height + 2 * margin
  35. }
  36. });
  37. }
  38. clip.isClip = true;
  39. return clip;
  40. }
  41. function isPointInPlot(point, plot) {
  42. var x = point.x,
  43. y = point.y;
  44. var tl = plot.tl,
  45. tr = plot.tr,
  46. br = plot.br;
  47. return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
  48. }