circle.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { __extends, __read } from "tslib";
  2. import { deepAssign, hide } from '../../util';
  3. import { circle } from '../marker/symbol';
  4. import { CrosshairBase } from './base';
  5. import { CIRCLE_CROSSHAIR_DEFAULT_STYLE } from './constant';
  6. var CircleCrosshair = /** @class */ (function (_super) {
  7. __extends(CircleCrosshair, _super);
  8. function CircleCrosshair(options) {
  9. return _super.call(this, deepAssign({}, CircleCrosshair.defaultOptions, options)) || this;
  10. }
  11. Object.defineProperty(CircleCrosshair.prototype, "crosshairPath", {
  12. get: function () {
  13. return this.createCirclePath();
  14. },
  15. enumerable: false,
  16. configurable: true
  17. });
  18. CircleCrosshair.prototype.update = function (cfg) {
  19. _super.prototype.update.call(this, cfg);
  20. };
  21. CircleCrosshair.prototype.setPointer = function (_a) {
  22. var _b = __read(_a, 2), x = _b[0], y = _b[1];
  23. _super.prototype.setPointer.call(this, [x, y]);
  24. var _c = __read(this.localPointer, 2), lx = _c[0], ly = _c[1];
  25. var _d = __read(this.attributes.center, 2), cx = _d[0], cy = _d[1];
  26. var path = this.createCirclePath(Math.pow((Math.pow((lx - cx), 2) + Math.pow((ly - cy), 2)), 0.5));
  27. this.crosshairShape.attr({ path: path });
  28. };
  29. CircleCrosshair.prototype.adjustLayout = function () {
  30. hide(this.tagShape);
  31. };
  32. CircleCrosshair.prototype.createCirclePath = function (radius) {
  33. var _a = this.attributes, _b = __read(_a.center, 2), x = _b[0], y = _b[1], defaultRadius = _a.defaultRadius;
  34. return circle(x, y, radius || defaultRadius);
  35. };
  36. CircleCrosshair.tag = 'circle-crosshair';
  37. CircleCrosshair.defaultOptions = {
  38. style: CIRCLE_CROSSHAIR_DEFAULT_STYLE,
  39. };
  40. return CircleCrosshair;
  41. }(CrosshairBase));
  42. export { CircleCrosshair };
  43. //# sourceMappingURL=circle.js.map