all files / circular-gauge/user-interaction/ tooltip.js

96.5% Statements 276/286
93.38% Branches 254/272
100% Functions 18/18
96.5% Lines 276/286
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 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444   137× 137× 137× 137×   1051× 1051× 1051× 1051× 1051× 1051× 1051× 1051× 1051× 1051× 643× 643× 643× 643×     408× 408× 408×   1051×   989× 394×   989× 989× 989× 989× 989× 989× 989× 989× 989× 989× 989× 989×     989× 989×     989× 989×     989× 989×   989×       989× 989× 989× 120×   989× 626× 242× 242×       384×       363× 363×   989× 989×               989× 989× 989× 989× 62×   989×         989× 989×   62×   36× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36×   36×     36× 36× 36× 36× 36× 36×     36× 36×     36×       36×       36× 36× 36×   36× 12× 12×   36× 30× 12× 12×       18×         36× 36×   36×   36×   36×   36×   36× 36× 36× 36×   36×         36× 36×   26×   16× 16× 16× 16× 16× 16× 16× 16× 16× 16× 16×   16× 16×     16×         16× 16× 16×   16× 16× 16× 16× 16× 16×   12×               12× 12× 12× 12×         16× 16×   10×                 1051× 1051× 1051× 1051×       1051×       1037×     1037×                                 1037× 120×   1037×   1041× 367×     674×       674× 674×     17× 17× 20× 16× 16×       1061×     1061×   650× 650× 650× 650× 650× 650×   75× 75× 75× 75× 75×   79× 79× 79× 79×   79× 79× 79× 79×   79× 79× 79× 79× 79×   98× 98× 98× 98× 98×   74× 74× 74× 74× 74×   85× 85× 85× 85× 85×   72× 72× 72× 72× 72×   650×   666× 666× 632× 632× 632× 632×   632×   666×   643× 643× 643× 643×   137×     137× 137× 137×   137× 14×     14× 14× 14×     1667×   137× 137× 137× 137× 137× 137× 137× 44×   137× 137× 137× 137× 137×        
define(["require", "exports", "@syncfusion/ej2-svg-base", "../utils/helper-common", "../utils/helper-tooltip", "@syncfusion/ej2-base", "../model/constants", "../utils/helper-legend"], function (require, exports, ej2_svg_base_1, helper_common_1, helper_tooltip_1, ej2_base_1, constants_1, helper_legend_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var GaugeTooltip = (function () {
        function GaugeTooltip(gauge) {
            this.gauge = gauge;
            this.tooltipId = this.gauge.element.id + '_CircularGauge_Tooltip';
            this.tooltip = gauge.tooltip;
            this.addEventListener();
        }
        GaugeTooltip.prototype.renderTooltip = function (e) {
            var _this = this;
            this.gaugeId = this.gauge.element.getAttribute('id');
            var pageX;
            var pageY;
            var target;
            var touchArg;
            var location;
            var samePointerEle = false;
            var isTooltipRender = false;
            if (e.type.indexOf('touch') !== -1) {
                touchArg = e;
                target = touchArg.target;
                pageX = touchArg.changedTouches[0].pageX;
                pageY = touchArg.changedTouches[0].pageY;
            }
            else {
                target = e.target;
                pageX = e.pageX;
                pageY = e.pageY;
            }
            if ((this.tooltip.type.indexOf('Pointer') > -1) && (target.id.indexOf('_Pointer_') >= 0) &&
                (target.id.indexOf(this.gaugeId) >= 0)) {
                if (this.pointerEle !== null) {
                    samePointerEle = (this.pointerEle === target);
                }
                isTooltipRender = true;
                var svgRect_1 = this.gauge.svgObject.getBoundingClientRect();
                var elementRect = this.gauge.element.getBoundingClientRect();
                var axisRect_1 = document.getElementById(this.gauge.element.id + '_AxesCollection').getBoundingClientRect();
                var rect_1 = new helper_common_1.Rect(Math.abs(elementRect.left - svgRect_1.left), Math.abs(elementRect.top - svgRect_1.top), svgRect_1.width, svgRect_1.height);
                var currentPointer = helper_common_1.getPointer(target.id, this.gauge);
                this.currentAxis = this.gauge.axes[currentPointer.axisIndex];
                this.currentPointer = (this.currentAxis.pointers)[currentPointer.pointerIndex];
                var angle_1 = helper_common_1.getAngleFromValue(this.currentPointer.currentValue, this.currentAxis.visibleRange.max, this.currentAxis.visibleRange.min, this.currentAxis.startAngle, this.currentAxis.endAngle, this.currentAxis.direction === 'ClockWise') % 360;
                var tooltipFormat = this.gauge.tooltip.format || this.currentAxis.labelStyle.format;
                var customLabelFormat = tooltipFormat && tooltipFormat.match('{value}') !== null;
                var format = this.gauge.intl.getNumberFormat({
                    format: helper_common_1.getLabelFormat(tooltipFormat), useGrouping: this.gauge.useGroupingSeparator
                });
                this.tooltipElement();
                Iif (this.tooltipEle.childElementCount !== 0 && !this.gauge.enablePointerDrag && !this.gauge.tooltip.showAtMousePosition) {
                    return null;
                }
                var roundValue = this.roundedValue(this.currentPointer.currentValue);
                var pointerContent = customLabelFormat ?
                    tooltipFormat.replace(new RegExp('{value}', 'g'), format(roundValue)) :
                    format(roundValue);
                location = helper_common_1.getLocationFromAngle(angle_1, this.currentAxis.currentRadius, this.gauge.midPoint);
                location.x = (this.tooltip.template && ((angle_1 >= 150 && angle_1 <= 250) || (angle_1 >= 330 && angle_1 <= 360) ||
                    (angle_1 >= 0 && angle_1 <= 45))) ? (location.x + 10) : location.x;
                var tooltipArgs = {
                    name: constants_1.tooltipRender, cancel: false, content: pointerContent, location: location, axis: this.currentAxis,
                    tooltip: this.tooltip, pointer: this.currentPointer, event: e, gauge: this.gauge, appendInBodyTag: false, type: 'Pointer'
                };
                var pointerTooltip = function (tooltipArgs) {
                    var template = tooltipArgs.tooltip.template;
                    if (template !== null && template.length === 1 && typeof template !== 'function') {
                        template = template[template[0]];
                    }
                    if (!tooltipArgs.tooltip.showAtMousePosition) {
                        if (template) {
                            var elementSize = helper_tooltip_1.getElementSize(template, _this.gauge, _this.tooltipEle);
                            _this.tooltipRect = Math.abs(axisRect_1.left - svgRect_1.left) > elementSize.width ?
                                _this.findPosition(rect_1, angle_1, tooltipArgs.location, true) : rect_1;
                        }
                        else {
                            _this.findPosition(rect_1, angle_1, tooltipArgs.location, false);
                        }
                    }
                    else {
                        tooltipArgs.location = helper_tooltip_1.getMousePosition(pageX, pageY, _this.gauge.svgObject);
                        _this.tooltipRect = rect_1;
                    }
                    Eif (!tooltipArgs.cancel && !samePointerEle) {
                        var pointerTextStyle = {
                            color: tooltipArgs.tooltip.textStyle.color || _this.gauge.themeStyle.tooltipFontColor,
                            opacity: tooltipArgs.tooltip.textStyle.opacity || _this.gauge.themeStyle.tooltipTextOpacity,
                            fontFamily: tooltipArgs.tooltip.textStyle.fontFamily || _this.gauge.themeStyle.fontFamily,
                            fontWeight: tooltipArgs.tooltip.textStyle.fontWeight || _this.gauge.themeStyle.fontWeight,
                            fontStyle: tooltipArgs.tooltip.textStyle.fontStyle,
                            size: tooltipArgs.tooltip.textStyle.size || _this.gauge.themeStyle.tooltipFontSize
                        };
                        _this.svgTooltip = _this.svgTooltipCreate(_this.svgTooltip, tooltipArgs, template, _this.arrowInverted, _this.tooltipRect, _this.gauge, tooltipArgs.tooltip.fill, pointerTextStyle, tooltipArgs.tooltip.border);
                        _this.svgTooltip.opacity = _this.gauge.themeStyle.tooltipFillOpacity || _this.svgTooltip.opacity;
                        _this.svgTooltip.appendTo(_this.tooltipEle);
                        if (template && (_this.tooltipPosition === 'LeftTop' || _this.tooltipPosition === 'LeftBottom')) {
                            _this.tooltipEle.style.left = (parseFloat(_this.tooltipEle.style.left) - _this.tooltipEle.getBoundingClientRect().width - 20) + 'px';
                        }
                        Iif (template && Math.abs(pageY - _this.tooltipEle.getBoundingClientRect().top) <= 0) {
                            _this.tooltipEle.style.top = (parseFloat(_this.tooltipEle.style.top) + 20) + 'px';
                        }
                    }
                };
                this.gauge.trigger(constants_1.tooltipRender, tooltipArgs, pointerTooltip);
                this.gauge.renderReactTemplates();
            }
            else if ((this.tooltip.type.indexOf('Range') > -1) && (target.id.indexOf('_Range_') >= 0) && (!this.gauge.isDrag) &&
                (target.id.indexOf(this.gaugeId) >= 0)) {
                isTooltipRender = true;
                var rangeSvgRect_1 = this.gauge.svgObject.getBoundingClientRect();
                var rangeElementRect = this.gauge.element.getBoundingClientRect();
                var rangeAxisRect_1 = document.getElementById(this.gauge.element.id + '_AxesCollection').getBoundingClientRect();
                var rect_2 = new helper_common_1.Rect(Math.abs(rangeElementRect.left - rangeSvgRect_1.left), Math.abs(rangeElementRect.top - rangeSvgRect_1.top), rangeSvgRect_1.width, rangeSvgRect_1.height);
                var currentRange = helper_common_1.getPointer(target.id, this.gauge);
                this.currentAxis = this.gauge.axes[currentRange.axisIndex];
                this.currentRange = (this.currentAxis.ranges)[currentRange.pointerIndex];
                var rangeAngle_1 = helper_common_1.getAngleFromValue((this.currentRange.end - Math.abs((this.currentRange.end - this.currentRange.start) / 2)), this.currentAxis.visibleRange.max, this.currentAxis.visibleRange.min, this.currentAxis.startAngle, this.currentAxis.endAngle, this.currentAxis.direction === 'ClockWise') % 360;
                var rangeTooltipFormat = this.gauge.tooltip.rangeSettings.format || this.currentAxis.labelStyle.format;
                var customLabelFormat = rangeTooltipFormat && (rangeTooltipFormat.match('{end}') !== null ||
                    rangeTooltipFormat.match('{start}') !== null);
                var rangeFormat = this.gauge.intl.getNumberFormat({
                    format: helper_common_1.getLabelFormat(rangeTooltipFormat), useGrouping: this.gauge.useGroupingSeparator
                });
                this.tooltipElement();
                var roundStartValue = this.roundedValue(this.currentRange.start);
                var roundEndValue = this.roundedValue(this.currentRange.end);
                var startData_1 = (this.currentRange.start).toString();
                var endData_1 = (this.currentRange.end).toString();
                var rangeContent = customLabelFormat ?
                    rangeTooltipFormat.replace(/{start}/g, startData_1).replace(/{end}/g, endData_1) : this.gauge.enableRtl ? 'Start:' + rangeFormat(roundStartValue) + ' <br>End:' + rangeFormat(roundEndValue) + ' ' :
                    'Start : ' + rangeFormat(roundStartValue) + '<br>' + 'End : ' + rangeFormat(roundEndValue);
                location = helper_common_1.getLocationFromAngle(rangeAngle_1, this.currentRange.currentRadius, this.gauge.midPoint);
                location.x = (this.tooltip.rangeSettings.template && ((rangeAngle_1 >= 150 && rangeAngle_1 <= 250) ||
                    (rangeAngle_1 >= 330 && rangeAngle_1 <= 360) ||
                    (rangeAngle_1 >= 0 && rangeAngle_1 <= 45))) ? (location.x + 10) : location.x;
                var rangeTooltipArgs = {
                    name: constants_1.tooltipRender, cancel: false, content: rangeContent, location: location, axis: this.currentAxis,
                    tooltip: this.tooltip, range: this.currentRange, event: e, gauge: this.gauge, appendInBodyTag: false, type: 'Range'
                };
                var rangeTooltipTextStyle_1 = { color: this.gauge.tooltip.rangeSettings.textStyle.color, opacity: this.gauge.tooltip.rangeSettings.textStyle.opacity,
                    fontFamily: this.gauge.tooltip.rangeSettings.textStyle.fontFamily, fontStyle: this.gauge.tooltip.rangeSettings.textStyle.fontStyle,
                    fontWeight: this.gauge.tooltip.rangeSettings.textStyle.fontWeight, size: this.gauge.tooltip.rangeSettings.textStyle.size
                };
                var rangeTooltip = function (rangeTooltipArgs) {
                    var rangeTemplate = rangeTooltipArgs.tooltip.rangeSettings.template;
                    if (rangeTemplate !== null && rangeTemplate.length === 1 && typeof rangeTemplate !== 'function') {
                        rangeTemplate = rangeTemplate[rangeTemplate[0]];
                    }
                    if (typeof rangeTemplate !== 'function' && rangeTemplate) {
                        rangeTemplate = rangeTemplate.replace(/[$]{start}/g, startData_1);
                        rangeTemplate = rangeTemplate.replace(/[$]{end}/g, endData_1);
                    }
                    if (!_this.tooltip.rangeSettings.showAtMousePosition) {
                        if (rangeTemplate) {
                            var elementSize = helper_tooltip_1.getElementSize(rangeTemplate, _this.gauge, _this.tooltipEle);
                            _this.tooltipRect = Math.abs(rangeAxisRect_1.left - rangeSvgRect_1.left) > elementSize.width ?
                                _this.findPosition(rect_2, rangeAngle_1, rangeTooltipArgs.location, true) : rect_2;
                        }
                        else {
                            _this.findPosition(rect_2, rangeAngle_1, rangeTooltipArgs.location, false);
                        }
                    }
                    else {
                        rangeTooltipArgs.location = helper_tooltip_1.getMousePosition(pageX, pageY, _this.gauge.svgObject);
                        _this.tooltipRect = rect_2;
                    }
                    Eif (!rangeTooltipArgs.cancel) {
                        rangeTooltipTextStyle_1.color = rangeTooltipArgs.tooltip.rangeSettings.textStyle.color ||
                            _this.gauge.themeStyle.tooltipFontColor;
                        rangeTooltipTextStyle_1.fontFamily = rangeTooltipArgs.tooltip.rangeSettings.textStyle.fontFamily
                            || _this.gauge.themeStyle.fontFamily;
                        rangeTooltipTextStyle_1.fontWeight = rangeTooltipArgs.tooltip.rangeSettings.textStyle.fontWeight
                            || _this.gauge.themeStyle.fontWeight;
                        rangeTooltipTextStyle_1.opacity = rangeTooltipArgs.tooltip.rangeSettings.textStyle.opacity ||
                            _this.gauge.themeStyle.tooltipTextOpacity;
                        rangeTooltipTextStyle_1.size = rangeTooltipArgs.tooltip.rangeSettings.textStyle.size
                            || _this.gauge.themeStyle.tooltipFontSize;
                        _this.svgTooltip = _this.svgTooltipCreate(_this.svgTooltip, rangeTooltipArgs, rangeTemplate, _this.arrowInverted, _this.tooltipRect, _this.gauge, rangeTooltipArgs.tooltip.rangeSettings.fill, rangeTooltipTextStyle_1, rangeTooltipArgs.tooltip.rangeSettings.border);
                        _this.svgTooltip.opacity = _this.gauge.themeStyle.tooltipFillOpacity || _this.svgTooltip.opacity;
                        _this.svgTooltip.appendTo(_this.tooltipEle);
                        if (rangeTemplate && (_this.tooltipPosition === 'LeftTop' || _this.tooltipPosition === 'LeftBottom')) {
                            _this.tooltipEle.style.left = (parseFloat(_this.tooltipEle.style.left) - _this.tooltipEle.getBoundingClientRect().width - 20) + 'px';
                        }
                        Iif (rangeTemplate && Math.abs(pageY - _this.tooltipEle.getBoundingClientRect().top) <= 0) {
                            _this.tooltipEle.style.top = (parseFloat(_this.tooltipEle.style.top) + 20) + 'px';
                        }
                    }
                };
                this.gauge.trigger(constants_1.tooltipRender, rangeTooltipArgs, rangeTooltip);
                this.gauge.renderReactTemplates();
            }
            else if ((this.tooltip.type.indexOf('Annotation') > -1) && this.checkParentAnnotationId(target) && ((!this.gauge.isDrag)) &&
                (this.annotationTargetElement.id.indexOf(this.gaugeId) >= 0)) {
                isTooltipRender = true;
                var annotationSvgRect = this.gauge.svgObject.getBoundingClientRect();
                var annotationElementRect = this.gauge.element.getBoundingClientRect();
                var rect_3 = new helper_common_1.Rect(Math.abs(annotationElementRect.left - annotationSvgRect.left), Math.abs(annotationElementRect.top - annotationSvgRect.top), annotationSvgRect.width, annotationSvgRect.height);
                var currentAnnotation = helper_common_1.getPointer(this.annotationTargetElement.id, this.gauge);
                this.currentAxis = this.gauge.axes[currentAnnotation.axisIndex];
                this.currentAnnotation = (this.currentAxis.annotations)[currentAnnotation.pointerIndex];
                var annotationAngle = (this.currentAnnotation.angle - 90);
                this.tooltipElement();
                document.getElementById(this.gauge.element.id + '_Secondary_Element').appendChild(this.tooltipEle);
                var annotationContent = (this.gauge.tooltip.annotationSettings.format !== null) ?
                    this.gauge.tooltip.annotationSettings.format : '';
                location = helper_common_1.getLocationFromAngle(annotationAngle, helper_common_1.stringToNumber(this.currentAnnotation.radius, this.currentAxis.currentRadius), this.gauge.midPoint);
                location.x = (this.tooltip.annotationSettings.template && ((annotationAngle >= 150 && annotationAngle <= 250) ||
                    (annotationAngle >= 330 && annotationAngle <= 360) || (annotationAngle >= 0 && annotationAngle <= 45))) ?
                    (location.x + 10) : location.x;
                var annotationTooltipArgs = {
                    name: constants_1.tooltipRender, cancel: false, content: annotationContent, location: location, axis: this.currentAxis,
                    tooltip: this.tooltip, annotation: this.currentAnnotation, event: e, gauge: this.gauge, appendInBodyTag: false,
                    type: 'Annotation'
                };
                var annotationTooltip = function (annotationTooltipArgs) {
                    var annotationTemplate = annotationTooltipArgs.tooltip.annotationSettings.template;
                    if (annotationTemplate !== null && annotationTemplate.length === 1 && typeof annotationTemplate !== 'function') {
                        annotationTemplate = annotationTemplate[annotationTemplate[0]];
                    }
                    var elementSizeAn = _this.annotationTargetElement.getBoundingClientRect();
                    _this.tooltipPosition = 'RightTop';
                    _this.arrowInverted = true;
                    annotationTooltipArgs.location.x = annotationTooltipArgs.location.x + (elementSizeAn.width / 2);
                    _this.tooltipRect = new helper_common_1.Rect(rect_3.x, rect_3.y, rect_3.width, rect_3.height);
                    if (!annotationTooltipArgs.cancel && (_this.gauge.tooltip.annotationSettings.format !== null ||
                        _this.gauge.tooltip.annotationSettings.template !== null)) {
                        var annotationTextStyle = {
                            color: annotationTooltipArgs.tooltip.textStyle.color || _this.gauge.themeStyle.tooltipFontColor,
                            fontFamily: annotationTooltipArgs.tooltip.textStyle.fontFamily || _this.gauge.themeStyle.fontFamily,
                            fontWeight: annotationTooltipArgs.tooltip.textStyle.fontWeight || _this.gauge.themeStyle.fontWeight,
                            opacity: annotationTooltipArgs.tooltip.textStyle.opacity || _this.gauge.themeStyle.tooltipTextOpacity,
                            fontStyle: annotationTooltipArgs.tooltip.textStyle.fontStyle,
                            size: annotationTooltipArgs.tooltip.textStyle.size || _this.gauge.themeStyle.tooltipFontSize
                        };
                        _this.svgTooltip = _this.svgTooltipCreate(_this.svgTooltip, annotationTooltipArgs, annotationTemplate, _this.arrowInverted, _this.tooltipRect, _this.gauge, annotationTooltipArgs.tooltip.annotationSettings.fill, annotationTextStyle, annotationTooltipArgs.tooltip.annotationSettings.border);
                        _this.svgTooltip.opacity = _this.gauge.themeStyle.tooltipFillOpacity || _this.svgTooltip.opacity;
                        _this.svgTooltip.appendTo(_this.tooltipEle);
                        Iif (annotationTemplate && Math.abs(pageY - _this.tooltipEle.getBoundingClientRect().top) <= 0) {
                            _this.tooltipEle.style.top = (parseFloat(_this.tooltipEle.style.top) + 20) + 'px';
                        }
                    }
                };
                this.gauge.trigger(constants_1.tooltipRender, annotationTooltipArgs, annotationTooltip);
                this.gauge.renderReactTemplates();
            }
            else if ((target.id === (this.gauge.element.id + '_CircularGaugeTitle') || target.id.indexOf('_gauge_legend_') > -1) &&
                (e.target.textContent.indexOf('...') > -1)) {
                helper_legend_1.titleTooltip(e, pageX, pageY, this.gauge, false);
            }
            else {
                var isTooltipRemoved = this.removeTooltip();
                if (isTooltipRemoved) {
                    Iif ((this.gauge.isVue || this.gauge.isVue3)) {
                        this.gauge.clearTemplate([this.tooltipEle.children[0].id], [0]);
                    }
                    else Eif (!this.gauge.isAngular) {
                        this.gauge.clearTemplate();
                    }
                }
            }
            var gaugeElement = document.getElementById(this.gaugeId);
            var gaugeRect = gaugeElement.getBoundingClientRect();
            var tooltipRect = isTooltipRender ? this.tooltipEle.getBoundingClientRect() : null;
            Iif (isTooltipRender && this.tooltipEle.offsetLeft < 0 && (tooltipRect.left - gaugeRect.left) < 0) {
                var tooltipLeft = this.tooltipEle.style.left.split('px')[0];
                this.tooltipEle.style.left = parseInt(tooltipLeft, 10) + (gaugeRect.left - tooltipRect.left) + 'px';
            }
            Iif (isTooltipRender && tooltipRect.top < 0) {
                this.tooltipEle.style.top = 0 + 'px';
            }
        };
        GaugeTooltip.prototype.svgTooltipCreate = function (svgTooltip, tooltipArg, template, arrowInverted, tooltipRect, gauge, fill, textStyle, border) {
            var borderObject = {
                color: border.color || this.gauge.themeStyle.tooltipBorderColor || '', width: border.width, dashArray: border.dashArray
            };
            svgTooltip = new ej2_svg_base_1.Tooltip({
                theme: gauge.theme,
                enable: true,
                data: { value: tooltipArg.content },
                template: template,
                enableRTL: gauge.enableRtl,
                enableAnimation: tooltipArg.tooltip.enableAnimation,
                content: [ej2_base_1.SanitizeHtmlHelper.sanitize(tooltipArg.content)],
                location: tooltipArg.location,
                inverted: arrowInverted,
                areaBounds: tooltipRect,
                fill: fill || gauge.themeStyle.tooltipFillColor,
                textStyle: textStyle,
                availableSize: gauge.availableSize,
                border: borderObject,
                enableShadow: true
            });
            if ((gauge.isVue || gauge.isVue3)) {
                svgTooltip.controlInstance = gauge;
            }
            return svgTooltip;
        };
        GaugeTooltip.prototype.tooltipElement = function () {
            if (document.getElementById(this.tooltipId)) {
                this.tooltipEle = document.getElementById(this.tooltipId);
            }
            else {
                this.tooltipEle = ej2_base_1.createElement('div', {
                    id: this.tooltipId,
                    className: 'EJ2-CircularGauge-Tooltip'
                });
                this.tooltipEle.style.cssText = 'position: absolute;pointer-events:none;';
                document.getElementById(this.gauge.element.id + '_Secondary_Element').appendChild(this.tooltipEle);
            }
        };
        GaugeTooltip.prototype.checkParentAnnotationId = function (child) {
            this.annotationTargetElement = child.parentElement;
            while (this.annotationTargetElement != null) {
                if ((this.annotationTargetElement.id.indexOf('_Annotation_') >= 0)) {
                    child = this.annotationTargetElement;
                    return true;
                }
                this.annotationTargetElement = this.annotationTargetElement.parentElement;
            }
            return false;
        };
        GaugeTooltip.prototype.roundedValue = function (currentValue) {
            var roundNumber = this.currentAxis.roundingPlaces ?
                parseFloat(currentValue.toFixed(this.currentAxis.roundingPlaces)) :
                currentValue;
            return roundNumber;
        };
        GaugeTooltip.prototype.findPosition = function (rect, angle, location, isTemplate) {
            var addLeft;
            var addTop;
            var addHeight;
            var addWidth;
            var padding = 10;
            switch (true) {
                case (angle >= 0 && angle < 45):
                    this.arrowInverted = true;
                    addLeft = (angle >= 15 && angle <= 30) ? location.y : 0;
                    this.tooltipRect = new helper_common_1.Rect(rect.x, rect.y + addTop, rect.width, rect.height);
                    this.tooltipPosition = 'RightBottom';
                    break;
                case (angle >= 45 && angle < 90):
                    this.arrowInverted = false;
                    this.tooltipRect = new helper_common_1.Rect(rect.x, rect.y + location.y, rect.width, rect.height);
                    this.tooltipPosition = 'BottomRight';
                    break;
                case (angle >= 90 && angle < 135):
                    this.arrowInverted = false;
                    this.tooltipRect = new helper_common_1.Rect(rect.x, rect.y + location.y, rect.width, rect.height);
                    this.tooltipPosition = 'BottomLeft';
                    break;
                case (angle >= 135 && angle < 180):
                    this.arrowInverted = isTemplate ? true : isTemplate;
                    addTop = (angle >= 150 && angle <= 160 && isTemplate) ? location.y : 0;
                    this.tooltipRect = new helper_common_1.Rect(rect.x, rect.y + addTop, rect.width, rect.height);
                    this.tooltipPosition = 'LeftBottom';
                    break;
                case (angle >= 180 && angle < 225):
                    this.arrowInverted = true;
                    addHeight = (angle >= 200 && angle <= 225) ? Math.abs(rect.y - location.y) : rect.height;
                    this.tooltipRect = new helper_common_1.Rect(rect.x - location.x, rect.y, rect.width, addHeight);
                    this.tooltipPosition = 'LeftTop';
                    break;
                case (angle >= 225 && angle < 270):
                    this.arrowInverted = false;
                    addWidth = (angle >= 250 && angle <= 290) ? rect.width : Math.abs(rect.x - location.x);
                    this.tooltipRect = new helper_common_1.Rect(rect.x + padding, rect.y, addWidth, rect.height);
                    this.tooltipPosition = 'TopLeft';
                    break;
                case (angle >= 270 && angle < 315):
                    this.arrowInverted = false;
                    addLeft = (angle >= 270 && angle > 290) ? location.x - padding : 0;
                    this.tooltipRect = new helper_common_1.Rect(rect.x + addLeft, rect.y, rect.width, rect.height);
                    this.tooltipPosition = 'TopRight';
                    break;
                case (angle >= 315 && angle <= 360):
                    this.arrowInverted = true;
                    addHeight = (angle >= 315 && angle <= 340) ? Math.abs(rect.y - location.y) : rect.height;
                    this.tooltipRect = new helper_common_1.Rect(rect.x, rect.y, rect.width, addHeight);
                    this.tooltipPosition = 'RightTop';
                    break;
            }
            return this.tooltipRect;
        };
        GaugeTooltip.prototype.removeTooltip = function () {
            var isTooltipRemoved = false;
            if (document.getElementsByClassName('EJ2-CircularGauge-Tooltip').length > 0) {
                var tooltip = document.getElementsByClassName('EJ2-CircularGauge-Tooltip')[0];
                Eif (tooltip) {
                    ej2_base_1.remove(tooltip);
                    isTooltipRemoved = true;
                }
                this.pointerEle = null;
            }
            return isTooltipRemoved;
        };
        GaugeTooltip.prototype.mouseUpHandler = function (e) {
            this.removeTooltip();
            this.renderTooltip(e);
            clearTimeout(this.clearTimeout);
            this.clearTimeout = setTimeout(this.removeTooltip.bind(this), 2000);
        };
        GaugeTooltip.prototype.addEventListener = function () {
            Iif (this.gauge.isDestroyed) {
                return;
            }
            this.gauge.on(ej2_base_1.Browser.touchMoveEvent, this.renderTooltip, this);
            this.gauge.on(ej2_base_1.Browser.touchEndEvent, this.mouseUpHandler, this);
            this.gauge.element.addEventListener('contextmenu', this.removeTooltip);
        };
        GaugeTooltip.prototype.removeEventListener = function () {
            if (this.gauge) {
                Iif (this.gauge.isDestroyed) {
                    return;
                }
                this.gauge.off(ej2_base_1.Browser.touchMoveEvent, this.renderTooltip);
                this.gauge.off(ej2_base_1.Browser.touchEndEvent, this.mouseUpHandler);
                this.gauge.element.removeEventListener('contextmenu', this.removeTooltip);
            }
        };
        GaugeTooltip.prototype.getModuleName = function () {
            return 'Tooltip';
        };
        GaugeTooltip.prototype.destroy = function () {
            this.tooltipEle = null;
            this.currentAxis = null;
            this.tooltip = null;
            this.currentPointer = null;
            this.currentRange = null;
            this.currentAnnotation = null;
            if (!ej2_base_1.isNullOrUndefined(this.svgTooltip)) {
                this.svgTooltip.destroy();
            }
            this.svgTooltip = null;
            this.tooltipRect = null;
            this.pointerEle = null;
            this.annotationTargetElement = null;
            this.gauge = null;
        };
        return GaugeTooltip;
    }());
    exports.GaugeTooltip = GaugeTooltip;
});