1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 'use strict';
- import H from './../../parts/Globals.js';
- import './../../parts/Utilities.js';
- import controllableMixin from './controllableMixin.js';
- import ControllablePath from './ControllablePath.js';
- /**
- * A controllable circle class.
- *
- * @constructor
- * @mixes Annotation.controllableMixin
- * @memberOf Annotation
- *
- * @param {Highcharts.Annotation} annotation an annotation instance
- * @param {Object} options a shape's options
- * @param {number} index of the circle
- **/
- function ControllableCircle(annotation, options, index) {
- this.init(annotation, options, index);
- this.collection = 'shapes';
- }
- /**
- * A map object which allows to map options attributes to element attributes.
- */
- ControllableCircle.attrsMap = H.merge(ControllablePath.attrsMap, {
- r: 'r'
- });
- H.merge(
- true,
- ControllableCircle.prototype,
- controllableMixin, /** @lends Annotation.ControllableCircle# */ {
- /**
- * @type 'circle'
- */
- type: 'circle',
- render: function (parent) {
- var attrs = this.attrsFromOptions(this.options);
- this.graphic = this.annotation.chart.renderer
- .circle(0, -9e9, 0)
- .attr(attrs)
- .add(parent);
- controllableMixin.render.call(this);
- },
- redraw: function (animation) {
- var position = this.anchor(this.points[0]).absolutePosition;
- if (position) {
- this.graphic[animation ? 'animate' : 'attr']({
- x: position.x,
- y: position.y,
- r: this.options.r
- });
- } else {
- this.graphic.attr({
- x: 0,
- y: -9e9
- });
- }
- this.graphic.placed = Boolean(position);
- controllableMixin.redraw.call(this, animation);
- },
- translate: function (dx, dy) {
- var annotationOptions = this.annotation.userOptions,
- shapeOptions = annotationOptions[this.collection][this.index];
- this.translatePoint(dx, dy, 0);
- // Options stored in chart:
- shapeOptions.point = this.options.point;
- },
- /**
- * Set the radius.
- *
- * @param {number} r a radius to be set
- */
- setRadius: function (r) {
- this.options.r = r;
- }
- }
- );
- export default ControllableCircle;
|