ControllableCircle.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* *
  2. *
  3. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4. *
  5. * */
  6. 'use strict';
  7. import ControllableMixin from '../Mixins/ControllableMixin.js';
  8. import ControllablePath from './ControllablePath.js';
  9. import U from '../../../Core/Utilities.js';
  10. var merge = U.merge;
  11. /* eslint-disable no-invalid-this, valid-jsdoc */
  12. /**
  13. * A controllable circle class.
  14. *
  15. * @requires modules/annotations
  16. *
  17. * @private
  18. * @class
  19. * @name Highcharts.AnnotationControllableCircle
  20. *
  21. * @param {Highcharts.Annotation} annotation an annotation instance
  22. * @param {Highcharts.AnnotationsShapeOptions} options a shape's options
  23. * @param {number} index of the circle
  24. */
  25. var ControllableCircle = /** @class */ (function () {
  26. /* *
  27. *
  28. * Constructors
  29. *
  30. * */
  31. function ControllableCircle(annotation, options, index) {
  32. /* *
  33. *
  34. * Properties
  35. *
  36. * */
  37. this.addControlPoints = ControllableMixin.addControlPoints;
  38. this.anchor = ControllableMixin.anchor;
  39. this.attr = ControllableMixin.attr;
  40. this.attrsFromOptions = ControllableMixin.attrsFromOptions;
  41. this.destroy = ControllableMixin.destroy;
  42. this.getPointsOptions = ControllableMixin.getPointsOptions;
  43. this.init = ControllableMixin.init;
  44. this.linkPoints = ControllableMixin.linkPoints;
  45. this.point = ControllableMixin.point;
  46. this.rotate = ControllableMixin.rotate;
  47. this.scale = ControllableMixin.scale;
  48. this.setControlPointsVisibility = ControllableMixin.setControlPointsVisibility;
  49. this.shouldBeDrawn = ControllableMixin.shouldBeDrawn;
  50. this.transform = ControllableMixin.transform;
  51. this.transformPoint = ControllableMixin.transformPoint;
  52. this.translatePoint = ControllableMixin.translatePoint;
  53. this.translateShape = ControllableMixin.translateShape;
  54. this.update = ControllableMixin.update;
  55. /**
  56. * @type 'circle'
  57. */
  58. this.type = 'circle';
  59. this.translate = ControllableMixin.translateShape;
  60. this.init(annotation, options, index);
  61. this.collection = 'shapes';
  62. }
  63. /* *
  64. *
  65. * Functions
  66. *
  67. * */
  68. ControllableCircle.prototype.render = function (parent) {
  69. var attrs = this.attrsFromOptions(this.options);
  70. this.graphic = this.annotation.chart.renderer
  71. .circle(0, -9e9, 0)
  72. .attr(attrs)
  73. .add(parent);
  74. ControllableMixin.render.call(this);
  75. };
  76. ControllableCircle.prototype.redraw = function (animation) {
  77. var position = this.anchor(this.points[0]).absolutePosition;
  78. if (position) {
  79. this.graphic[animation ? 'animate' : 'attr']({
  80. x: position.x,
  81. y: position.y,
  82. r: this.options.r
  83. });
  84. }
  85. else {
  86. this.graphic.attr({
  87. x: 0,
  88. y: -9e9
  89. });
  90. }
  91. this.graphic.placed = Boolean(position);
  92. ControllableMixin.redraw.call(this, animation);
  93. };
  94. /**
  95. * Set the radius.
  96. *
  97. * @param {number} r a radius to be set
  98. */
  99. ControllableCircle.prototype.setRadius = function (r) {
  100. this.options.r = r;
  101. };
  102. /* *
  103. *
  104. * Static Properties
  105. *
  106. * */
  107. /**
  108. * A map object which allows to map options attributes to element
  109. * attributes.
  110. *
  111. * @name Highcharts.AnnotationControllableCircle.attrsMap
  112. * @type {Highcharts.Dictionary<string>}
  113. */
  114. ControllableCircle.attrsMap = merge(ControllablePath.attrsMap, { r: 'r' });
  115. return ControllableCircle;
  116. }());
  117. export default ControllableCircle;