all files / circular-gauge/axes/ pointer-renderer.js

98.77% Statements 241/244
83.58% Branches 280/335
100% Functions 25/25
99.18% Lines 241/243
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417   670×   742× 742× 742×     742× 742× 736× 848× 17×     831×   848× 848× 848×     848× 565× 565×   848× 848× 17×     831×   848× 848× 819× 819×     736×     848× 848×       33× 13× 13× 13× 13×           13×     20× 20× 20×     20×           20×     598× 598× 598× 598× 598× 598× 598× 598× 598× 598× 598× 598× 598× 598× 598× 598×       597×     598× 598×   598×   598× 598×   598× 598×   598× 246× 246×       246× 246×   598× 598×   598× 584×   598×   4143× 4143× 4143× 4143× 4143× 4143× 4143×   4143× 4143× 4143× 4078× 2251×       1827×       65×       4143× 156× 156× 156×   4143×   4143×   4143×   4143×   4143×   4143× 63× 63×   4143×     4143× 11388× 514× 308× 308×     206×       10874× 21×     10853×         21× 21× 21× 21× 21×   134× 134× 134× 134× 134× 134× 134× 134×   134×         134× 134× 20×               20×   20× 20× 20×     114×     116× 116× 116× 116×   116×     831× 831× 831× 831×   283× 686× 54×     632×     628×                         151× 91× 88× 88× 88× 88× 88× 88× 88× 88×                         3508× 3508× 3508× 3508× 3508× 3508× 3508× 3508× 3508×               1910× 1037×     1037× 1037× 1037×   1037×         2930× 2886× 2886×   2886×   2891× 964×   2891×     2888×         55× 55× 55× 55× 55× 55× 55× 55×               435× 390× 390× 390× 390×       10× 10× 10×   10× 10×             653×        
define(["require", "exports", "../utils/helper-common", "../utils/helper-pointer-renderer", "@syncfusion/ej2-base", "../model/constants"], function (require, exports, helper_common_1, helper_pointer_renderer_1, ej2_base_1, constants_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PointerRenderer = (function () {
        function PointerRenderer(gauge) {
            this.gauge = gauge;
        }
        PointerRenderer.prototype.drawPointers = function (axis, axisIndex, element, gauge, animate) {
            var _this = this;
            Iif (animate === void 0) { animate = true; }
            var pointerElement = gauge.renderer.createGroup({
                id: gauge.element.id + '_Axis_Pointers_' + axisIndex
            });
            var childElement;
            if (this.gauge.allowComponentRender) {
                axis.pointers.map(function (pointer, pointerIndex) {
                    if (!ej2_base_1.isNullOrUndefined(pointer.offset) && pointer.offset.length > 0) {
                        pointer.currentDistanceFromScale = helper_common_1.stringToNumber(pointer.offset, axis.currentRadius);
                    }
                    else {
                        pointer.currentDistanceFromScale = pointer.offset;
                    }
                    pointer.pathElement = [];
                    _this.calculatePointerRadius(axis, pointer);
                    childElement = gauge.renderer.createGroup({
                        id: gauge.element.id + '_Axis_' + axisIndex + '_Pointer_' + pointerIndex
                    });
                    if (pointer.value != null) {
                        childElement.setAttribute('aria-label', pointer.description || 'Pointer:' + pointer.value.toString());
                        childElement.setAttribute('role', 'region');
                    }
                    _this['draw' + pointer.type + 'Pointer'](axis, axisIndex, pointerIndex, childElement, gauge);
                    if (_this.gauge.allowLoadingAnimation) {
                        childElement.style.visibility = 'hidden';
                    }
                    else {
                        _this.setPointerValue(axis, pointer, pointer.currentValue);
                    }
                    pointerElement.appendChild(childElement);
                    if (!_this.gauge.allowLoadingAnimation && ((animate || pointer.animation.enable) || ej2_base_1.animationMode === 'Enable') && (!_this.gauge.isPropertyChange || pointer.isPointerAnimation)) {
                        pointer.previousValue = !_this.gauge.isPropertyChange ? axis.minimum : pointer.previousValue;
                        _this.doPointerAnimation(childElement, pointer, axis, axisIndex);
                    }
                });
                element.appendChild(pointerElement);
            }
        };
        PointerRenderer.prototype.calculatePointerRadius = function (axis, pointer) {
            var padding = 5;
            pointer.currentRadius = !ej2_base_1.isNullOrUndefined(pointer.radius) ?
                helper_common_1.stringToNumber(pointer.radius, axis.currentRadius) : pointer.position !== 'Auto' ?
                this.pointerRadiusForPosition(axis, pointer) : (axis.currentRadius - (axis.farSize + padding));
        };
        PointerRenderer.prototype.pointerRadiusForPosition = function (axis, pointer) {
            if (pointer.markerShape === 'Text') {
                var pointerRadius = void 0;
                var pointerSize = parseInt(pointer.textStyle.size, 10);
                var markerOffset = pointer.position === 'Cross' ? pointerSize / 5 : 0;
                pointerRadius = pointer.position === 'Inside' ?
                    (axis.currentRadius - pointerSize / 1.2 - axis.lineStyle.width / 2 - markerOffset - pointer.currentDistanceFromScale) :
                    pointer.position === 'Outside' ?
                        (axis.currentRadius + axis.lineStyle.width / 2 + pointerSize / 4 + markerOffset +
                            pointer.currentDistanceFromScale) :
                        (axis.currentRadius - pointerSize / 6 - markerOffset - pointer.currentDistanceFromScale);
                return pointerRadius;
            }
            else {
                var pointerRadius = void 0;
                var rangeBarOffset = pointer.type === 'RangeBar' ? pointer.pointerWidth : 0;
                var markerOffset = pointer.type === 'Marker' ? ((pointer.markerShape === 'InvertedTriangle' ||
                    pointer.markerShape === 'Triangle') ? (pointer.position === 'Cross' ? pointer.markerWidth / 2 : 0) :
                    pointer.markerWidth / 2) : 0;
                pointerRadius = pointer.position === 'Inside' ?
                    (axis.currentRadius - axis.lineStyle.width / 2 - markerOffset - pointer.currentDistanceFromScale) :
                    pointer.position === 'Outside' ?
                        (axis.currentRadius + rangeBarOffset + axis.lineStyle.width / 2 + markerOffset + pointer.currentDistanceFromScale) :
                        (axis.currentRadius + rangeBarOffset / 2 - pointer.currentDistanceFromScale -
                            ((pointer.markerShape === 'InvertedTriangle' || pointer.markerShape === 'Triangle') ? markerOffset : 0));
                return pointerRadius;
            }
        };
        PointerRenderer.prototype.drawNeedlePointer = function (axis, axisIndex, index, parentElement, gauge) {
            var pointer = axis.pointers[index];
            var needle = pointer.needleTail;
            var cap = pointer.cap;
            var pointerRadius;
            var location;
            var direction;
            var needleStartWidth = pointer.needleStartWidth;
            var needleEndWidth = pointer.needleEndWidth;
            var mid = gauge.midPoint;
            var width = pointer.pointerWidth / 2;
            var rectDirection;
            var gradientColor;
            var gradientTailColor;
            var gradientCapColor;
            location = helper_common_1.getLocationFromAngle(0, pointer.currentRadius, mid);
            if ((needleStartWidth === 0) && (needleEndWidth === 0) && width) {
                direction = 'M ' + mid.x + ' ' + (mid.y) + ' L ' + (location.x) + ' ' + mid.y +
                    ' L ' + (mid.x) + ' ' + (mid.y) + ' Z';
            }
            else {
                direction = 'M ' + mid.x + ' ' + (mid.y - width - needleEndWidth) + ' L ' + (location.x) + ' ' + mid.y +
                    ' L ' + location.x + ' ' + (mid.y + needleStartWidth) + ' L ' + mid.x + ' ' + (mid.y + width + needleEndWidth) + ' Z';
            }
            Eif (gauge.gradientModule) {
                gradientColor = gauge.gradientModule.getGradientColorString(pointer);
            }
            pointer.pathElement.push(helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_Axis_' + axisIndex + '_Pointer_Needle_' + index, gradientColor ? gradientColor :
                pointer.color || this.gauge.themeStyle.needleColor, pointer.border.width, pointer.border.color, null, pointer.border.dashArray, direction), parentElement, gauge));
            pointerRadius = helper_common_1.stringToNumber(pointer.needleTail.length, pointer.currentRadius);
            rectDirection = 'M ' + mid.x + ' ' + (mid.y - width) + ' L ' + (location.x) + ' ' + (mid.y - width) +
                ' L ' + location.x + ' ' + (mid.y + width) + ' L ' + mid.x + ' ' + (mid.y + width);
            Eif (gauge.gradientModule) {
                gradientTailColor = gauge.gradientModule.getGradientColorString(needle);
            }
            if (pointerRadius) {
                location = helper_common_1.getLocationFromAngle(180, pointerRadius, gauge.midPoint);
                direction = 'M ' + mid.x + ' ' + (mid.y - width) +
                    ' L ' + (location.x) + ' ' + (mid.y - width) +
                    ' L ' + (location.x) + ' ' + (mid.y + width) +
                    ' L ' + (mid.x) + ' ' + (mid.y + width) + ' Z';
                pointer.pathElement.push(helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_Axis_' + axisIndex + '_Pointer_NeedleTail_' + index, gradientTailColor ? gradientTailColor : pointer.needleTail.color || this.gauge.themeStyle.needleTailColor, pointer.needleTail.border.width, pointer.needleTail.border.color, null, pointer.needleTail.border.dashArray, direction), parentElement, gauge));
                rectDirection += ' L ' + location.x + ' ' + (mid.y + width) + ' L ' + location.x + ' ' + (mid.y - width);
            }
            Eif (gauge.gradientModule) {
                gradientCapColor = gauge.gradientModule.getGradientColorString(cap);
            }
            if (pointer.cap.radius) {
                pointer.pathElement.push(helper_common_1.appendPath(helper_common_1.calculateShapes(mid, 'Circle', new helper_common_1.Size(pointer.cap.radius * 2, pointer.cap.radius * 2), '', new helper_common_1.PathOption(gauge.element.id + '_Axis_' + axisIndex + '_Pointer_NeedleCap_' + index, gradientCapColor ? gradientCapColor : pointer.cap.color || this.gauge.themeStyle.capColor, pointer.cap.border.width, pointer.cap.border.color, null, pointer.cap.border.dashArray, '', '')), parentElement, gauge, 'Ellipse'));
            }
            pointer.pathElement.push(helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_Axis_' + axisIndex + '_Pointer_NeedleRect_' + index, 'transparent', 0, 'transpanret', null, '0', rectDirection + ' Z'), parentElement, gauge));
        };
        PointerRenderer.prototype.setPointerValue = function (axis, pointer, value) {
            var _this = this;
            var checkMinValue = value === axis.visibleRange.min && pointer.type === 'RangeBar';
            var location = this.gauge.midPoint;
            var isClockWise = axis.direction === 'ClockWise';
            var radius = pointer.roundedCornerRadius;
            var minRadius = (radius * 0.25);
            if (radius > 0 && radius <= 5) {
                radius = 6;
                minRadius = (radius * 0.25);
            }
            var startAngle = helper_common_1.getAngleFromValue(axis.visibleRange.min, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, isClockWise);
            var endAngle = helper_common_1.getAngleFromValue(value, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, isClockWise);
            if (isClockWise) {
                if (startAngle > endAngle) {
                    endAngle = Math.round(startAngle) === Math.round(endAngle) && !checkMinValue ?
                        Math.round(endAngle) - (pointer.roundedCornerRadius > 0 ? 1.5 : 0.5) : Math.round(endAngle);
                }
                else {
                    endAngle = startAngle === endAngle && !checkMinValue ? endAngle + 1 : endAngle;
                }
            }
            else {
                endAngle = Math.round(startAngle) === Math.round(endAngle) && !checkMinValue ?
                    [startAngle, startAngle = (endAngle > startAngle ? endAngle + (pointer.roundedCornerRadius > 0 ? 1.5 : 0.5) : endAngle - 1)][0]
                    : [startAngle, startAngle = endAngle][0];
            }
            if (value <= (axis.visibleRange.min + axis.visibleRange.interval) && pointer.roundedCornerRadius) {
                radius = value === axis.visibleRange.min || (axis.visibleRange.min + 1) ? 8 : radius;
                radius /= 2;
                minRadius = radius * 0.25;
            }
            var oldStartValue = ((((pointer.currentRadius - (pointer.pointerWidth / 2)) * ((startAngle * Math.PI) / 180) -
                (radius / minRadius)) / (pointer.currentRadius - (pointer.pointerWidth / 2))) * 180) / Math.PI;
            var oldEndValue = ((((pointer.currentRadius - (pointer.pointerWidth / 2)) * ((endAngle * Math.PI) / 180) +
                (radius / minRadius)) / (pointer.currentRadius - (pointer.pointerWidth / 2))) * 180) / Math.PI;
            var angleValue = value === axis.maximum && (axis.startAngle === axis.endAngle ||
                Math.abs(axis.startAngle - axis.endAngle) === 360) && pointer.type === 'RangeBar' ? 45 : 180;
            var roundStartAngle = ((((pointer.currentRadius) * ((startAngle * Math.PI) / angleValue) +
                radius) / (pointer.currentRadius)) * angleValue) / Math.PI;
            var roundEndAngle = ((((pointer.currentRadius) * ((endAngle * Math.PI) / angleValue) -
                radius) / (pointer.currentRadius)) * angleValue) / Math.PI;
            if (roundStartAngle > roundEndAngle && (roundStartAngle - roundEndAngle) <= 36 && pointer.type === 'RangeBar') {
                roundStartAngle = startAngle;
                roundEndAngle = endAngle;
            }
            Iif (ej2_base_1.isNullOrUndefined(pointer.currentRadius)) {
                this.calculatePointerRadius(axis, pointer);
            }
            pointer.pathElement.map(function (element) {
                if (pointer.type === 'RangeBar') {
                    if (radius && !checkMinValue) {
                        element.setAttribute('d', helper_common_1.getRoundedPathArc(location, Math.floor(roundStartAngle), Math.ceil(roundEndAngle), oldStartValue, oldEndValue, pointer.currentRadius, pointer.pointerWidth, pointer.pointerWidth));
                        radius = 0;
                    }
                    else {
                        element.setAttribute('d', helper_pointer_renderer_1.getCompleteArc(location, startAngle, endAngle, pointer.currentRadius, (pointer.currentRadius - pointer.pointerWidth), checkMinValue));
                    }
                }
                else {
                    if (pointer.type === 'Marker' && pointer.markerShape === 'Text') {
                        _this.calculateTextElement(axis, pointer, value, element);
                    }
                    else {
                        element.setAttribute('transform', 'rotate(' + helper_common_1.getAngleFromValue(value, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, isClockWise) + ',' + location.x + ',' + location.y + ')');
                    }
                }
            });
        };
        PointerRenderer.prototype.calculateTextElement = function (axis, pointer, value, element) {
            var textangle = helper_common_1.getAngleFromValue(value, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, axis.direction === 'ClockWise');
            var textlocation = helper_common_1.getLocationFromAngle(textangle, pointer.currentRadius, this.gauge.midPoint);
            element.setAttribute('transform', 'rotate(' + (textangle + 90) + ',' + textlocation.x + ',' + textlocation.y + ')');
            element.setAttribute('x', String(textlocation.x));
            element.setAttribute('y', String(textlocation.y));
        };
        PointerRenderer.prototype.drawMarkerPointer = function (axis, axisIndex, index, parentElement, gauge) {
            var pointer = axis.pointers[index];
            var min = axis.visibleRange.min;
            var max = axis.visibleRange.max;
            var gradientMarkerColor;
            var angle = Math.round(helper_common_1.getAngleFromValue(pointer.value, max, min, axis.startAngle, axis.endAngle, axis.direction === 'ClockWise'));
            var shapeBasedOnPosition = pointer.markerShape;
            Eif (gauge.gradientModule) {
                gradientMarkerColor = gauge.gradientModule.getGradientColorString(pointer);
            }
            if (ej2_base_1.isNullOrUndefined(pointer.radius) && !ej2_base_1.isNullOrUndefined(pointer.position) && (pointer.markerShape === 'InvertedTriangle' ||
                pointer.markerShape === 'Triangle')) {
                shapeBasedOnPosition = ((pointer.position === 'Outside' || pointer.position === 'Cross') && pointer.markerShape === 'Triangle' ?
                    'InvertedTriangle' : (pointer.position === 'Inside' &&
                    pointer.markerShape === 'InvertedTriangle' ? 'Triangle' : pointer.markerShape));
            }
            var location = helper_common_1.getLocationFromAngle((pointer.markerShape === 'Text') ? angle : 0, pointer.currentRadius, gauge.midPoint);
            if (pointer.markerShape === 'Text') {
                var style = {
                    size: pointer.textStyle.size,
                    color: pointer.textStyle.color || this.gauge.themeStyle.pointerColor,
                    fontFamily: pointer.textStyle.fontFamily,
                    fontStyle: pointer.textStyle.fontStyle,
                    fontWeight: pointer.textStyle.fontWeight || this.gauge.themeStyle.fontWeight,
                    opacity: pointer.textStyle.opacity
                };
                var textOption = new helper_common_1.TextOption(gauge.element.id + '_Axis_' + axisIndex + '_Pointer_Marker_' + index, location.x, location.y, 'middle', pointer.text, 'rotate(' + (angle + 90) + ',' +
                    (location.x) + ',' + location.y + ')', 'auto');
                var textObject = helper_common_1.textElement(textOption, style, style.color, parentElement, 'pointer-events : auto; ');
                textObject.style.visibility = ((pointer.animation.enable || ej2_base_1.animationMode === 'Enable') && (!this.gauge.isPropertyChange || pointer.isPointerAnimation) && this.gauge.animatePointer) ? 'hidden' : 'visible';
                pointer.pathElement.push(textObject);
            }
            else {
                pointer.pathElement.push(helper_common_1.appendPath(helper_common_1.calculateShapes(location, shapeBasedOnPosition, new helper_common_1.Size(pointer.markerWidth, pointer.markerHeight), pointer.imageUrl, new helper_common_1.PathOption(gauge.element.id + '_Axis_' + axisIndex + '_Pointer_Marker_' + index, gradientMarkerColor ? gradientMarkerColor : pointer.color || this.gauge.themeStyle.pointerColor, pointer.border.width, pointer.border.color, null, pointer.border.dashArray, '', '')), parentElement, gauge, pointer.markerShape === 'Circle' ? 'Ellipse' : (pointer.markerShape === 'Image' ? 'Image' : 'Path')));
            }
        };
        PointerRenderer.prototype.drawRangeBarPointer = function (axis, axisIndex, index, parentElement, gauge) {
            var pointer = axis.pointers[index];
            var gradientBarColor;
            Eif (gauge.gradientModule) {
                gradientBarColor = gauge.gradientModule.getGradientColorString(pointer);
            }
            pointer.pathElement.push(helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_Axis_' + axisIndex + '_Pointer_RangeBar_' + index, gradientBarColor ? gradientBarColor :
                pointer.color || this.gauge.themeStyle.pointerColor, pointer.border.width, pointer.border.color, 1, pointer.border.dashArray, ''), parentElement, gauge));
        };
        PointerRenderer.prototype.doPointerAnimation = function (pointerElement, pointer, axis, axisIndex) {
            var _this = this;
            var startValue = !ej2_base_1.isNullOrUndefined(pointer.previousValue) ? pointer.previousValue : axis.visibleRange.min;
            var endValue = pointer.currentValue;
            if (((pointer.animation.enable || ej2_base_1.animationMode === 'Enable') && startValue !== endValue && this.gauge.animatePointer) ||
                (!ej2_base_1.isNullOrUndefined(this.gauge.loadingAnimationDuration) && this.gauge.loadingAnimationDuration[axisIndex] > 0)) {
                pointer.pathElement.map(function (element) {
                    if (pointer.type === 'RangeBar') {
                        _this.performRangeBarAnimation(element, startValue, endValue, axis, pointer, axisIndex);
                    }
                    else {
                        if (pointer.type === 'Marker' && pointer.markerShape === 'Text') {
                            _this.performTextAnimation(pointerElement, startValue, endValue, axis, pointer, axisIndex);
                        }
                        else {
                            _this.performNeedleAnimation(element, startValue, endValue, axis, pointer, axisIndex);
                        }
                    }
                });
            }
        };
        PointerRenderer.prototype.performTextAnimation = function (element, start, end, axis, pointer, axisIndex) {
            var _this = this;
            var isClockWise = axis.direction === 'ClockWise';
            var textangle;
            var textlocation;
            var pointerValue = 0;
            var timeStamp;
            start = typeof (start) === 'string' ? parseInt(start, 10) : start;
            end = typeof (end) === 'string' ? parseInt(end, 10) : end;
            element = !ej2_base_1.isNullOrUndefined(element.children[0]) ? element.children[0] : element;
            var val = Math.abs(start - end);
            new ej2_base_1.Animation({}).animate(element, {
                duration: this.gauge.isAnimationProgress ? (ej2_base_1.isNullOrUndefined(pointer.value) || pointer.value === axis.minimum ? 0 :
                    (ej2_base_1.animationMode === 'Enable' && (((!pointer.animation.enable || pointer.animation.duration === 0)
                        && !this.gauge.allowLoadingAnimation) || (this.gauge.allowLoadingAnimation && (this.gauge.animationDuration === 0
                        && pointer.animation.enable && pointer.animation.duration === 0)))) ? 1000 :
                        (this.gauge.allowLoadingAnimation ? (pointer.animation.enable && pointer.animation.duration > 0 ? pointer.animation.duration
                            : this.gauge.loadingAnimationDuration[axisIndex]) : pointer.animation.duration)) : 0,
                progress: function (args) {
                    if (_this.gauge.isAnimationProgress) {
                        if (args.timeStamp > args.delay) {
                            timeStamp = (args.timeStamp / pointer.animation.duration);
                            pointerValue = end > start ? start + (timeStamp * val) : start - (timeStamp * val);
                            textangle = helper_common_1.getAngleFromValue(pointerValue, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, isClockWise);
                            textlocation = helper_common_1.getLocationFromAngle(textangle, pointer.currentRadius, _this.gauge.midPoint);
                            element.setAttribute('transform', 'rotate(' + (textangle + 90) + ',' + textlocation.x + ',' + textlocation.y + ')');
                            element.setAttribute('x', String(textlocation.x));
                            element.setAttribute('y', String(textlocation.y));
                            element.style.visibility = 'visible';
                        }
                    }
                },
                end: function () {
                    if (_this.gauge.isAnimationProgress) {
                        _this.setPointerValue(axis, pointer, end);
                        pointer.isPointerAnimation = false;
                    }
                    _this.gauge.trigger(constants_1.animationComplete, { axis: axis, pointer: pointer });
                    Iif (!ej2_base_1.isNullOrUndefined(_this.gauge.loadingAnimationDuration) && (_this.gauge.loadingAnimationDuration[axisIndex] > 0 && !ej2_base_1.isNullOrUndefined(_this.gauge.annotationsModule))) {
                        _this.gauge.annotationsModule.annotationAnimation(_this.gauge);
                    }
                    else {
                        _this.gauge.isOverAllAnimationComplete = true;
                    }
                }
            });
        };
        PointerRenderer.prototype.performNeedleAnimation = function (element, start, end, axis, pointer, axisIndex) {
            var _this = this;
            var isClockWise = axis.direction === 'ClockWise';
            start = typeof (start) === 'string' ? parseInt(start, 10) : start;
            end = typeof (end) === 'string' ? parseInt(end, 10) : end;
            var startAngle = helper_common_1.getAngleFromValue(start, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, isClockWise);
            var pointAngle = helper_common_1.getAngleFromValue(end, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, isClockWise);
            var endAngle = startAngle > pointAngle ? (pointAngle + 360) : pointAngle;
            var sweepAngle;
            new ej2_base_1.Animation({}).animate(element, {
                duration: this.gauge.isAnimationProgress ? (ej2_base_1.isNullOrUndefined(pointer.value) || pointer.value === axis.minimum ? 0 :
                    (ej2_base_1.animationMode === 'Enable' && (((!pointer.animation.enable || pointer.animation.duration === 0)
                        && !this.gauge.allowLoadingAnimation) || (this.gauge.allowLoadingAnimation && (this.gauge.animationDuration === 0
                        && pointer.animation.enable && pointer.animation.duration === 0)))) ? 1000 :
                        (this.gauge.allowLoadingAnimation ? (pointer.animation.enable && pointer.animation.duration > 0 ? pointer.animation.duration
                            : this.gauge.loadingAnimationDuration[axisIndex]) : pointer.animation.duration)) : 0,
                progress: function (args) {
                    if (_this.gauge.isAnimationProgress) {
                        sweepAngle = (start < end || Math.round(startAngle) === Math.round(endAngle)) ?
                            isClockWise ? (endAngle - startAngle) : (endAngle - startAngle - 360) :
                            isClockWise ? (endAngle - startAngle - 360) : (endAngle - startAngle);
                        element.style.animation = 'None';
                        Eif (start !== end) {
                            element.setAttribute('transform', 'rotate(' + helper_pointer_renderer_1.linear(args.timeStamp, startAngle, sweepAngle, args.duration) + ',' +
                                _this.gauge.midPoint.x.toString() + ',' + _this.gauge.midPoint.y.toString() + ')');
                            element.style.visibility = 'visible';
                        }
                    }
                },
                end: function () {
                    if (_this.gauge.isAnimationProgress) {
                        _this.setPointerValue(axis, pointer, end);
                        if (_this.gauge.animationDuration > 0) {
                            element.style.visibility = 'visible';
                        }
                        pointer.isPointerAnimation = false;
                    }
                    if (pointer.type === 'Marker' || (element.id.indexOf('_Pointer_NeedleCap') >= 0)) {
                        _this.gauge.trigger(constants_1.animationComplete, { axis: axis, pointer: pointer });
                    }
                    if (!ej2_base_1.isNullOrUndefined(_this.gauge.loadingAnimationDuration) && _this.gauge.loadingAnimationDuration[axisIndex] > 0 && !ej2_base_1.isNullOrUndefined(_this.gauge.annotationsModule)) {
                        _this.gauge.annotationsModule.annotationAnimation(_this.gauge);
                    }
                    else {
                        _this.gauge.isOverAllAnimationComplete = true;
                    }
                }
            });
        };
        PointerRenderer.prototype.performRangeBarAnimation = function (element, start, end, axis, pointer, axisIndex) {
            var _this = this;
            start = typeof (start) === 'string' ? parseInt(start, 10) : start;
            end = typeof (end) === 'string' ? parseInt(end, 10) : end;
            var pointerValue;
            var timeStamp;
            element.style.visibility = 'visible';
            var val = Math.abs(start - end);
            new ej2_base_1.Animation({}).animate(element, {
                duration: this.gauge.isAnimationProgress ? (ej2_base_1.isNullOrUndefined(pointer.value) || pointer.value === axis.minimum ? 0 :
                    (ej2_base_1.animationMode === 'Enable' && (((!pointer.animation.enable || pointer.animation.duration === 0)
                        && !this.gauge.allowLoadingAnimation) || (this.gauge.allowLoadingAnimation && (this.gauge.animationDuration === 0
                        && pointer.animation.enable && pointer.animation.duration === 0)))) ? 1000 :
                        (this.gauge.allowLoadingAnimation ? (pointer.animation.enable && pointer.animation.duration > 0 ? pointer.animation.duration
                            : this.gauge.loadingAnimationDuration[axisIndex]) : pointer.animation.duration)) : 0,
                progress: function (arg) {
                    Eif (_this.gauge.isAnimationProgress) {
                        arg.duration = !_this.gauge.isAnimationProgress ? 0 : arg.duration;
                        timeStamp = (arg.timeStamp / arg.duration);
                        pointerValue = end > start ? start + (timeStamp * val) : start - (timeStamp * val);
                        _this.setPointerValue(axis, pointer, pointerValue);
                    }
                },
                end: function () {
                    Eif (_this.gauge.isAnimationProgress) {
                        _this.setPointerValue(axis, pointer, end);
                        pointer.isPointerAnimation = false;
                    }
                    _this.gauge.trigger(constants_1.animationComplete, { axis: axis, pointer: pointer });
                    if (!ej2_base_1.isNullOrUndefined(_this.gauge.loadingAnimationDuration) && _this.gauge.loadingAnimationDuration[axisIndex] > 0 && !ej2_base_1.isNullOrUndefined(_this.gauge.annotationsModule)) {
                        _this.gauge.annotationsModule.annotationAnimation(_this.gauge);
                    }
                    else {
                        _this.gauge.isOverAllAnimationComplete = true;
                    }
                }
            });
        };
        PointerRenderer.prototype.destroy = function () {
            this.gauge = null;
        };
        return PointerRenderer;
    }());
    exports.PointerRenderer = PointerRenderer;
});