helper.js 1.1 KB

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