all files / chart/series/ data-label.js

97.76% Statements 480/491
90.3% Branches 652/722
100% Functions 27/27
97.76% Lines 479/490
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 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793   987× 987×   2149× 2149× 2149× 2149× 2149× 2017× 2017×   2149× 2138×         2138×         2138×   2149× 2149× 2149× 2149×     2149× 2087×   62× 61× 61× 61× 61×                         56× 50× 50×           56× 54× 49×                   38705×   2149× 2149× 2149× 2149×   2149×     2149× 2149× 2041× 14401×     2149× 56× 54×           14624×     14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624× 14624×   14287× 14287× 14287× 17377×           17377× 17377× 17377× 17377× 17377× 17377× 525×     16852× 51×     16801×   16852× 16852× 16852× 51× 51× 51× 51× 51× 34× 34× 34× 123×               16801×   16852× 15881× 15881× 4837× 4837× 4837×     15881× 15881× 15881× 15881× 15881× 15881× 15881× 30× 30× 30×     15851× 15851× 15851× 15851× 15851×   15881×   15881× 15881× 2812×   15881×   15881× 295×   15881× 1132×     971× 62×           14624×   51× 51× 51× 51× 51×   51× 153× 17×     34×   525× 525× 525×           525×   525× 525× 525× 525× 525× 525×     525× 525× 525× 525× 525× 525× 525×   525×               436× 436× 436×   428× 16×       17377× 17377× 480×   17377× 17377× 17377× 17377× 17377× 15064× 15064×   15064×   15064×     15064× 374×       2313× 2313× 2313×   2313×   17377× 17377×     17028× 17028× 17028×   17028×   17028×   17377× 17377× 297×   17377× 17377×   374× 374× 374× 374× 374× 374× 278×       96×     374× 374× 66×   308× 192×   374× 24×     350×         342× 32×     310×     302× 222×       80×     374× 374× 374× 66×     308× 116×     374× 374×   17377× 17377× 17377× 960×   17377× 17377× 17377× 17377× 840× 840×   151× 151×   151× 151×   151× 151×   151× 151×   151× 151×   85× 85× 85×     840× 50×     790×     16537× 24×   16513× 15797×   716× 236×   480×       480×   17377× 480×         480× 480×     17377×   16803× 374×   16429× 16429× 16429×   16429×   16429× 1052×   15377× 3291×   12086× 72×   16429×   738×         738×   645×     645×   5770× 5770×   9276× 9276× 9276×   16429×   16429×     16429× 16429× 68× 68× 68× 68× 68× 68× 68×     68×       16429×   14326× 14326×   182×   14326× 14326×     4298×   4298×   4185×   4185×   4857× 4857×   14326×   17377× 17377× 17377× 12066×     5770× 5770× 5770× 5770× 5770× 5770× 5770× 6727× 6727× 6727× 2588× 2588×   6727× 6727× 5102×     5102× 5102× 5102× 4021×       1625× 1625×     6727×   5770×   6472×   93×   93×   457×   457×   6472×   9276× 9276× 9276×           2516× 2516× 2516×   538×   538× 538×   1159× 492× 492×     667×       667×     1159×   5063× 1873×       3190×     5063×   9276×   3546× 3546× 3358× 1636×       1722×         188× 94×       94×       3546×   4857× 4857× 4857× 4857× 4857× 4857× 4857× 4857× 4857× 4857× 4857× 4857× 4857× 141×   4716× 137× 137× 118×       4579× 390× 180×   210× 140×     70× 70× 70×       4189× 478×     3711× 472×       3239×   3238× 108×       3130× 3130× 3130×         4857× 4857× 4857× 6955× 6955× 6955×   6955× 6955×   4857×   171× 171× 171× 171× 171× 171× 171× 171× 1269× 1269×     1261× 1261× 1261× 56× 56× 56×         13682×   41538×          
define(["require", "exports", "../../common/utils/helper", "../../common/utils/helper", "../../common/utils/helper", "@syncfusion/ej2-svg-base", "../../common/model/constants", "../../common/utils/helper", "@syncfusion/ej2-base", "../../common/utils/helper"], function (require, exports, helper_1, helper_2, helper_3, ej2_svg_base_1, constants_1, helper_4, ej2_base_1, helper_5) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DataLabel = (function () {
        function DataLabel(chart) {
            this.errorHeight = 0;
            this.chart = chart;
        }
        DataLabel.prototype.initPrivateVariables = function (series, marker) {
            var transform = '';
            var clipPath = '';
            var render = series.chart.renderer;
            var index = (series.index === undefined) ? series.category : series.index;
            if (series.chart.chartAreaType === 'Cartesian') {
                transform = 'translate(' + series.clipRect.x + ',' + (series.clipRect.y) + ')';
                clipPath = 'url(#' + this.chart.element.id + '_ChartSeriesClipRect_' + index + ')';
            }
            if (marker.dataLabel.visible && !this.chart.enableCanvas) {
                series.shapeElement = render.createGroup({
                    'id': this.chart.element.id + 'ShapeGroup' + index,
                    'transform': transform,
                    'clip-path': 'url(#' + this.chart.element.id + '_ChartSeriesClipRect_' + index + ')'
                });
                series.textElement = render.createGroup({
                    'id': this.chart.element.id + 'TextGroup' + index,
                    'transform': transform,
                    'clip-path': clipPath
                });
                series.textElement.setAttribute('aria-hidden', 'true');
            }
            this.markerHeight = ((series.type === 'Scatter' || marker.visible)) ? (marker.height / 2) : 0;
            this.commonId = this.chart.element.id + '_Series_' + index + '_Point_';
            this.calculateErrorHeight(series, series.marker.dataLabel.position);
            this.chartBackground = this.chart.chartArea.background === 'transparent' ?
                this.chart.background || this.chart.themeStyle.background : this.chart.chartArea.background;
        };
        DataLabel.prototype.calculateErrorHeight = function (series, position) {
            if (!series.errorBar.visible) {
                return null;
            }
            else if (series.errorBar.visible && this.chart.chartAreaType !== 'PolarRadar') {
                var direction = series.errorBar.direction;
                var positiveHeight = this.chart.errorBarModule.positiveHeight;
                var negativeHeight = this.chart.errorBarModule.negativeHeight;
                if (this.isRectSeries(series)) {
                    if (position === 'Top' || position === 'Auto') {
                        Eif (direction === 'Both' || direction === 'Minus') {
                            this.errorHeight = negativeHeight;
                        }
                        else {
                            this.errorHeight = 0;
                        }
                    }
                    if (position === 'Outer' || position === 'Auto') {
                        Eif (direction === 'Both' || direction === 'Plus') {
                            this.errorHeight = positiveHeight;
                        }
                        else {
                            this.errorHeight = 0;
                        }
                    }
                }
                else {
                    if (position === 'Top' || position === 'Outer' || position === 'Auto') {
                        Eif ((direction === 'Both' || direction === 'Plus') && (!series.chart.isTransposed)) {
                            this.errorHeight = positiveHeight;
                        }
                        else {
                            this.errorHeight = 0;
                        }
                    }
                    if (position === 'Bottom' || position === 'Auto') {
                        if (direction === 'Both' || direction === 'Minus') {
                            this.errorHeight = negativeHeight;
                        }
                        else {
                            this.errorHeight = 0;
                        }
                    }
                }
            }
            else {
                this.errorHeight = 0;
            }
        };
        DataLabel.prototype.isRectSeries = function (series) {
            return series.isRectSeries || series.type === 'RangeArea' || series.type === 'SplineRangeArea' || series.type === 'RangeStepArea';
        };
        DataLabel.prototype.render = function (series, chart, dataLabel) {
            this.initPrivateVariables(series, series.marker);
            this.inverted = chart.requireInvertedAxis;
            this.yAxisInversed = series.yAxis.isAxisInverse;
            var templateId = chart.element.id + '_Series_' +
                (series.index === undefined ? series.category : series.index) + '_DataLabelCollections';
            var element = ej2_base_1.createElement('div', {
                id: templateId
            });
            var visiblePoints = helper_2.getVisiblePoints(series);
            if (series.visible) {
                for (var i = 0; i < visiblePoints.length; i++) {
                    this.renderDataLabel(series, visiblePoints[i], element, dataLabel);
                }
            }
            if (element.childElementCount) {
                if (!chart.enableCanvas) {
                    helper_2.appendChildElement(chart.enableCanvas, helper_4.getElement(chart.element.id + '_Secondary_Element'), element, chart.redraw, false, 'x', 'y', null, '', false, false, null, chart.duration);
                }
                else {
                    helper_4.getElement(chart.element.id + '_Secondary_Element').appendChild(element);
                }
            }
        };
        DataLabel.prototype.renderDataLabel = function (series, point, element, dataLabel) {
            Iif (!dataLabel.showZero && ((point.y === 0) || (point.y === 0 && series.emptyPointSettings.mode === 'Zero'))) {
                return null;
            }
            this.margin = dataLabel.margin;
            var labelText = [];
            var labelLength;
            var xPos;
            var yPos;
            var xValue;
            var yValue;
            var degree;
            var rectCenterX;
            var rectCenterY;
            var labelLocation = { x: 0, y: 0 };
            var textSize;
            var clip = series.clipRect;
            var shapeRect;
            var isDataLabelOverlap = false;
            var dataLabelElement = [];
            dataLabel.angle = dataLabel.labelIntersectAction === 'Rotate90' ? 90 : dataLabel.angle;
            dataLabel.enableRotation = dataLabel.labelIntersectAction === 'Rotate90' ? true : dataLabel.enableRotation;
            var angle = degree = dataLabel.angle;
            var border = { width: dataLabel.border.width, color: dataLabel.border.color };
            var argsFont = (ej2_base_1.extend({}, ej2_base_1.getValue('properties', dataLabel.font), null, true));
            if ((point.symbolLocations.length && point.symbolLocations[0]) ||
                (series.type === 'BoxAndWhisker' && point.regions.length)) {
                labelText = point.text !== null ? helper_3.getLabelText(point, series, this.chart) : [];
                labelLength = labelText.length;
                for (var i = 0; i < labelLength; i++) {
                    var argsData = {
                        cancel: false, name: constants_1.textRender, series: series,
                        point: point, text: labelText[i], border: border,
                        color: dataLabel.fill, template: dataLabel.template, font: argsFont, location: labelLocation,
                        textSize: ej2_svg_base_1.measureText(labelText[i], dataLabel.font, this.chart.themeStyle.datalabelFont)
                    };
                    this.chart.trigger(constants_1.textRender, argsData);
                    Eif (!argsData.cancel) {
                        this.fontBackground = argsData.color;
                        this.isDataLabelShape(argsData);
                        this.markerHeight = series.type === 'Bubble' ? (point.regions[0].height / 2) : this.markerHeight;
                        if (argsData.template !== null) {
                            this.createDataLabelTemplate(element, series, dataLabel, point, argsData, i, this.chart.redraw);
                        }
                        else {
                            if (dataLabel.enableRotation) {
                                textSize = helper_1.rotateTextSize(dataLabel.font, argsData.text, dataLabel.angle, this.chart, this.chart.themeStyle.datalabelFont);
                            }
                            else {
                                textSize = ej2_svg_base_1.measureText(argsData.text, dataLabel.font, this.chart.themeStyle.datalabelFont);
                            }
                            var rect = this.calculateTextPosition(point, series, textSize, dataLabel, i);
                            var actualRect = new ej2_svg_base_1.Rect(rect.x + clip.x, rect.y + clip.y, rect.width, rect.height);
                            if (dataLabel.enableRotation) {
                                var rectCoordinates = this.getRectanglePoints(rect);
                                rectCenterX = rect.x + (rect.width / 2);
                                rectCenterY = (rect.y + (rect.height / 2));
                                isDataLabelOverlap = (dataLabel.labelIntersectAction === 'Rotate90' || angle === -90) ? false : this.isDataLabelOverlapWithChartBound(rectCoordinates, this.chart, clip);
                                if (!isDataLabelOverlap) {
                                    this.chart.rotatedDataLabelCollections.push(rectCoordinates);
                                    var currentPointIndex = this.chart.rotatedDataLabelCollections.length - 1;
                                    for (var index = currentPointIndex; index >= 0; index--) {
                                        if (this.chart.rotatedDataLabelCollections[currentPointIndex] &&
                                            this.chart.rotatedDataLabelCollections[index - 1] &&
                                            helper_5.isRotatedRectIntersect(this.chart.rotatedDataLabelCollections[currentPointIndex], this.chart.rotatedDataLabelCollections[index - 1])) {
                                            isDataLabelOverlap = true;
                                            this.chart.rotatedDataLabelCollections[currentPointIndex] = null;
                                            break;
                                        }
                                    }
                                }
                            }
                            else {
                                isDataLabelOverlap = helper_1.isCollide(rect, this.chart.dataLabelCollections, clip);
                            }
                            if ((!isDataLabelOverlap || dataLabel.labelIntersectAction === 'None')) {
                                this.chart.dataLabelCollections.push(actualRect);
                                if (this.isShape) {
                                    shapeRect = this.chart.renderer.drawRectangle(new helper_1.RectOption(this.commonId + point.index + '_TextShape_' + i, argsData.color, argsData.border, dataLabel.opacity, rect, dataLabel.rx, dataLabel.ry, '', dataLabel.border.dashArray), new Int32Array([clip.x, clip.y]));
                                    Eif (series.shapeElement) {
                                        series.shapeElement.appendChild(shapeRect);
                                    }
                                }
                                var backgroundColor = this.fontBackground === 'transparent' ? ((this.chart.theme.indexOf('Dark') > -1 || this.chart.theme.indexOf('HighContrast') > -1) ? 'black' : 'white') : this.fontBackground;
                                var rgbValue = helper_3.convertHexToColor(helper_3.colorNameToHex(backgroundColor));
                                var contrast = Math.round((rgbValue.r * 299 + rgbValue.g * 587 + rgbValue.b * 114) / 1000);
                                xPos = (rect.x + this.margin.left + textSize.width / 2) + labelLocation.x;
                                yPos = dataLabel.enableRotation && this.chart.chartAreaType !== 'PolarRadar' ? (rect.y + this.margin.top + textSize.height / 2 + textSize.width / 4 + (dataLabel.position === 'Auto' ? point.regions[0].width / 10 : 0)) + labelLocation.y : (rect.y + this.margin.top + textSize.height * 3 / 4) + labelLocation.y;
                                labelLocation = { x: 0, y: 0 };
                                if (angle !== 0 && dataLabel.enableRotation) {
                                    xValue = rectCenterX;
                                    yValue = rectCenterY;
                                    degree = (angle > 360) ? angle - 360 : (angle < -360) ? angle + 360 : angle;
                                }
                                else {
                                    degree = 0;
                                    xValue = rect.x;
                                    yValue = rect.y;
                                    xPos -= this.chart.chartAreaType === 'Cartesian' && xPos + (textSize.width / 2) > clip.width ? (!this.chart.requireInvertedAxis && xPos > clip.width) ? 0 : (xPos + textSize.width / 2) - clip.width : 0;
                                    yPos -= (yPos + textSize.height > clip.y + clip.height && !(series.type.indexOf('Bar') > -1)) ? (yPos + textSize.height) - (clip.y + clip.height) : 0;
                                }
                                var textAnchor = dataLabel.labelIntersectAction === 'Rotate90' ? (dataLabel.position === 'Top' ? 'start' : (dataLabel.position === 'Middle' ? 'middle' : 'end')) :
                                    ((angle === -90 && dataLabel.enableRotation) ? (dataLabel.position === 'Top' ? 'end' : (dataLabel.position === 'Middle' ? 'middle' : 'start')) : 'middle');
                                var oldText = void 0;
                                if (this.chart.redraw && document.getElementById(this.commonId + point.index + '_Text_' + i)) {
                                    oldText = document.getElementById(this.commonId + point.index + '_Text_' + i).textContent;
                                }
                                dataLabelElement.push(helper_3.textElement(this.chart.renderer, new ej2_svg_base_1.TextOption(this.commonId + ((series.removedPointIndex !== null && series.removedPointIndex <= point.index) ? (point.index + 1) : point.index) + '_Text_' + i, xPos, yPos, textAnchor, argsData.text, 'rotate(' + degree + ',' + (xValue) + ',' + (yValue) + ')', 'auto', degree), argsData.font, argsData.font.color || (this.chart.theme === 'Bootstrap5' ? '#212529' : this.chart.theme === 'Bootstrap5Dark' ? '#DEE2E6' :
                                    ((contrast >= 128 || series.type === 'Hilo' || series.type === 'HiloOpenClose') ? 'black' : 'white')), series.textElement, false, this.chart.redraw, true, false, series.chart.duration, series.clipRect, null, null, this.chart.enableCanvas, null, this.chart.themeStyle.datalabelFont, new helper_1.ChartLocation(xValue, yValue)));
                                if (series.removedPointIndex !== null && series.removedPointIndex <= point.index) {
                                    series.textElement.lastChild.id = this.commonId + point.index + '_Text_' + i;
                                }
                                if (this.chart.redraw && oldText !== argsData.text) {
                                    helper_3.animateTextElement(series.textElement.querySelector('#' + this.commonId + point.index + '_Text_' + i), this.chart.duration, parseFloat(oldText), parseFloat(argsData.text), series.marker.dataLabel.format || series.yAxis.labelFormat);
                                }
                            }
                            else if (helper_4.getElement(this.commonId + point.index + '_Text_0') && series.chart.redraw && series.currentData) {
                                helper_4.getElement(this.commonId + point.index + '_Text_0').remove();
                            }
                        }
                    }
                }
            }
            return dataLabelElement;
        };
        DataLabel.prototype.getRectanglePoints = function (rect) {
            var loc1 = new helper_1.ChartLocation(rect.x, rect.y);
            var loc2 = new helper_1.ChartLocation(rect.x + rect.width, rect.y);
            var loc3 = new helper_1.ChartLocation(rect.x + rect.width, rect.y + rect.height);
            var loc4 = new helper_1.ChartLocation(rect.x, rect.y + rect.height);
            return [loc1, loc2, loc3, loc4];
        };
        DataLabel.prototype.isDataLabelOverlapWithChartBound = function (rectCoordinates, chart, clip) {
            for (var index = 0; index < rectCoordinates.length; index++) {
                if (!helper_4.withInBounds(rectCoordinates[index].x + clip.x, rectCoordinates[index].y + clip.y, chart.initialClipRect)) {
                    return true;
                }
            }
            return false;
        };
        DataLabel.prototype.createDataLabelTemplate = function (parentElement, series, dataLabel, point, data, labelIndex, redraw) {
            this.margin = { left: 0, right: 0, bottom: 0, top: 0 };
            var clip = series.clipRect;
            var childElement = helper_4.createTemplate(ej2_base_1.createElement('div', {
                id: this.chart.element.id + '_Series_' + (series.index === undefined ? series.category : series.index) + '_DataLabel_'
                    + point.index + (labelIndex ? ('_' + labelIndex) : ''),
                styles: 'position: absolute;background-color:' + data.color + ';' +
                    helper_4.getFontStyle(dataLabel.font, this.chart.themeStyle.datalabelFont) + ';border:' + data.border.width + 'px solid ' + data.border.color + ';'
            }), point.index, (this.chart.enableHtmlSanitizer ? this.chart.sanitize(data.template) : data.template), this.chart, point, series, this.chart.element.id + '_DataLabel', labelIndex);
            this.calculateTemplateLabelSize(parentElement, childElement, point, series, dataLabel, labelIndex, clip, redraw);
        };
        DataLabel.prototype.calculateTemplateLabelSize = function (parentElement, childElement, point, series, dataLabel, labelIndex, clip, redraw, isReactCallback) {
            var elementRect = helper_4.measureElementRect(childElement, redraw, isReactCallback);
            var rect = this.calculateTextPosition(point, series, { width: elementRect.width, height: elementRect.height }, dataLabel, labelIndex);
            var clipWidth = 0;
            var clipHeight = 0;
            var isOverlap = false;
            Iif (isReactCallback) {
                isOverlap = (elementRect.width === 0 || elementRect.height === 0);
            }
            childElement.style.left = ((this.chart.chartAreaType === 'PolarRadar' ? 0 : series.clipRect.x) + rect.x - clipWidth) + 'px';
            childElement.style.top = ((this.chart.chartAreaType === 'PolarRadar' ? 0 : series.clipRect.y) + rect.y + clipHeight) + 'px';
            var backgroundColor = this.fontBackground === 'transparent' ? (this.chart.theme.indexOf('Dark') > -1 ? 'black' : 'white') : this.fontBackground;
            var rgbValue = helper_3.convertHexToColor(helper_3.colorNameToHex(backgroundColor));
            var vAxis = series.chart.requireInvertedAxis ? series.xAxis : series.yAxis;
            var hAxis = series.chart.requireInvertedAxis ? series.yAxis : series.xAxis;
            childElement.style.color = dataLabel.font.color || (this.chart.theme === 'Bootstrap5' ? '#212529' : this.chart.theme === 'Bootstrap5Dark' ? '#DEE2E6' :
                ((Math.round((rgbValue.r * 299 + rgbValue.g * 587 + rgbValue.b * 114) / 1000)) >= 128 ? 'black' : 'white'));
            if (childElement.childElementCount && !isOverlap && (!helper_1.isCollide(rect, this.chart.dataLabelCollections, clip) ||
                dataLabel.labelIntersectAction === 'None') && (series.seriesType !== 'XY' || point.yValue === undefined ||
                helper_4.withIn(point.yValue, series.yAxis.visibleRange) || (series.type.indexOf('Stacking') > -1) ||
                (series.type.indexOf('100') > -1 && helper_4.withIn(series.stackedValues.endValues[point.index], series.yAxis.visibleRange))) &&
                helper_4.withIn(point.xValue, series.xAxis.visibleRange) && parseFloat(childElement.style.top) >= vAxis.rect.y &&
                parseFloat(childElement.style.left) >= hAxis.rect.x &&
                parseFloat(childElement.style.top) <= vAxis.rect.y + vAxis.rect.height &&
                parseFloat(childElement.style.left) <= hAxis.rect.x + hAxis.rect.width) {
                this.chart.dataLabelCollections.push(new ej2_svg_base_1.Rect(rect.x + clip.x, rect.y + clip.y, rect.width, rect.height));
                helper_2.appendChildElement(this.chart.enableCanvas, parentElement, childElement, redraw, true, 'left', 'top');
                if (series.animation.enable && this.chart.animateSeries && !this.chart.enableCanvas) {
                    this.doDataLabelAnimation(series, childElement);
                }
                else if (this.chart.enableCanvas) {
                    parentElement.appendChild(childElement);
                }
            }
        };
        DataLabel.prototype.calculateTextPosition = function (point, series, textSize, dataLabel, labelIndex) {
            var labelRegion = labelIndex > 1 ? (series.type === 'Candle') ? point.regions[1] : point.regions[0] : point.regions[0];
            if (labelIndex > 1 && series.type === 'HiloOpenClose') {
                labelRegion = (labelIndex === 2) ? point.regions[1] : point.regions[2];
            }
            var location;
            location = this.getLabelLocation(point, series, textSize, labelIndex);
            var padding = 5;
            var clipRect = series.clipRect;
            if (!this.chart.requireInvertedAxis || !this.isRectSeries(series) || series.type === 'BoxAndWhisker') {
                this.locationX = location.x;
                var alignmentValue = textSize.height + (this.borderWidth * 2) + this.markerHeight +
                    this.margin.bottom + this.margin.top + padding;
                location.x = (dataLabel.position === 'Auto') ? location.x :
                    this.calculateAlignment(alignmentValue, location.x, dataLabel.alignment, this.isRectSeries(series) ? point.yValue < 0 : false);
                location.y = (!this.isRectSeries(series) || series.type === 'BoxAndWhisker') ?
                    this.calculatePathPosition(location.y, dataLabel.position, series, point, textSize, labelIndex) :
                    this.calculateRectPosition(location.y, labelRegion, point.yValue < 0 !== this.yAxisInversed, dataLabel.position, series, textSize, labelIndex, point);
                if (this.isRectSeries(series) && this.chart.chartAreaType === 'PolarRadar') {
                    location = this.calculatePolarRectPosition(location, dataLabel.position, series, point, textSize, labelIndex, dataLabel.alignment, alignmentValue);
                }
            }
            else {
                this.locationY = location.y;
                var alignmentValue = textSize.width + this.borderWidth + this.margin.left + this.margin.right - padding;
                location.x = dataLabel.position === 'Auto' ? location.x :
                    this.calculateAlignment(alignmentValue, location.x, dataLabel.alignment, point.yValue < 0);
                location.x = this.calculateRectPosition(location.x, labelRegion, point.yValue < 0 !== this.yAxisInversed, dataLabel.position, series, textSize, labelIndex, point);
            }
            var rect = helper_3.calculateRect(location, textSize, this.margin);
            if (!(dataLabel.enableRotation === true && dataLabel.angle !== 0) &&
                !((rect.y > (clipRect.y + clipRect.height)) || (rect.x > (clipRect.x + clipRect.width)) ||
                    (rect.x + rect.width < 0) || (rect.y + rect.height < 0))) {
                rect.x = rect.x < 0 ? padding : rect.x;
                rect.y = (rect.y < 0 && !this.chart.requireInvertedAxis) && !(dataLabel.labelIntersectAction === 'None') ? padding : rect.y;
                rect.x -= (rect.x + rect.width) > (clipRect.x + clipRect.width) ? (rect.x + rect.width)
                    - (clipRect.x + clipRect.width) + padding : 0;
                rect.y -= (rect.y + rect.height) > (clipRect.y + clipRect.height) ? (rect.y + rect.height)
                    - (clipRect.y + clipRect.height) + padding : 0;
                this.fontBackground = this.fontBackground === 'transparent' ? this.chartBackground : this.fontBackground;
            }
            var dataLabelOutRegion;
            if (this.inverted && series.isRectSeries && (rect.x + rect.width > labelRegion.x + labelRegion.width)) {
                dataLabelOutRegion = true;
            }
            this.fontBackground = dataLabelOutRegion ? this.chartBackground : this.fontBackground;
            return rect;
        };
        DataLabel.prototype.calculatePolarRectPosition = function (location, position, series, point, size, labelIndex, alignment, alignmentValue) {
            var padding = 5;
            var columnRadius;
            var chartWidth = this.chart.availableSize.width;
            var alignmentSign = (alignment === 'Center') ? 0 : (alignment === 'Far' ? 1 : -1);
            var angle = (point.regionData.startAngle - 0.5 * Math.PI) + (point.regionData.endAngle - point.regionData.startAngle) / 2;
            if (labelIndex === 0) {
                columnRadius = point.regionData.radius < point.regionData.innerRadius ? point.regionData.innerRadius
                    : point.regionData.radius;
            }
            else {
                columnRadius = point.regionData.radius > point.regionData.innerRadius ? point.regionData.innerRadius
                    : point.regionData.radius;
            }
            this.fontBackground = this.fontBackground === 'transparent' ? this.chartBackground : this.fontBackground;
            if (series.drawType.indexOf('Stacking') > -1) {
                position = position === 'Outer' ? 'Top' : position;
            }
            else if (series.drawType.indexOf('Range') > -1) {
                position = (position === 'Outer' || position === 'Top') ? position : 'Auto';
            }
            if (position === 'Outer') {
                columnRadius = labelIndex === 0 ? columnRadius + 2 * padding + this.markerHeight :
                    columnRadius - 2 * padding - this.markerHeight;
            }
            else if (position === 'Middle') {
                columnRadius = columnRadius / 2 + padding;
                Iif (series.drawType === 'StackingColumn') {
                    columnRadius = point.regionData.innerRadius + ((point.regionData.radius - point.regionData.innerRadius) / 2)
                        + padding - (size.height / 2);
                }
            }
            else if (position === 'Top') {
                columnRadius = labelIndex === 0 ? columnRadius - 2 * padding - this.markerHeight :
                    columnRadius + 2 * padding + this.markerHeight;
            }
            else if (position === 'Bottom') {
                columnRadius = 2 * padding;
                columnRadius += (series.drawType === 'StackingColumn') ? (point.regionData.innerRadius + this.markerHeight) : 0;
            }
            else {
                if (labelIndex === 0) {
                    columnRadius = columnRadius >= series.chart.radius ? columnRadius - padding :
                        series.drawType === 'StackingColumn' ? columnRadius - 2 * padding : columnRadius + 2 * padding;
                }
                else {
                    columnRadius = columnRadius >= series.chart.radius ? columnRadius + padding : columnRadius - 2 * padding;
                }
            }
            columnRadius += (alignmentValue * alignmentSign);
            location.x = series.clipRect.width / 2 + series.clipRect.x + columnRadius * Math.cos(angle);
            if (series.drawType === 'StackingColumn') {
                location.x = location.x < chartWidth / 2 ? location.x + size.width / 2 :
                    (location.x > chartWidth / 2 ? location.x - size.width / 2 : location.x);
            }
            else if (series.drawType === 'Column') {
                location.x = location.x < chartWidth / 2 ? location.x - size.width / 2 :
                    (location.x > chartWidth / 2 ? location.x + size.width / 2 : location.x);
            }
            location.y = series.clipRect.height / 2 + series.clipRect.y + columnRadius * Math.sin(angle);
            return location;
        };
        DataLabel.prototype.getLabelLocation = function (point, series, textSize, labelIndex) {
            var location = new helper_1.ChartLocation(0, 0);
            var labelRegion = (series.type === 'Candle' && labelIndex > 1) ? point.regions[1] : point.regions[0];
            if (series.type === 'HiloOpenClose') {
                labelRegion = (labelIndex === 2) ? point.regions[1] : point.regions[2];
            }
            var xAxis = series.xAxis;
            var yAxis = series.yAxis;
            var isInverted = series.chart.requireInvertedAxis;
            if (series.type === 'BoxAndWhisker') {
                this.markerHeight = 0;
                switch (labelIndex) {
                    case 0:
                        location = helper_5.getPoint(point.xValue, point.median, xAxis, yAxis, isInverted);
                        break;
                    case 1:
                        location = helper_5.getPoint(point.xValue, point.maximum, xAxis, yAxis, isInverted);
                        break;
                    case 2:
                        location = helper_5.getPoint(point.xValue, point.minimum, xAxis, yAxis, isInverted);
                        break;
                    case 3:
                        location = helper_5.getPoint(point.xValue, point.upperQuartile, xAxis, yAxis, isInverted);
                        break;
                    case 4:
                        location = helper_5.getPoint(point.xValue, point.lowerQuartile, xAxis, yAxis, isInverted);
                        break;
                    default: {
                        location = helper_5.getPoint(point.xValue, point.outliers[labelIndex - 5], xAxis, yAxis, isInverted);
                        this.markerHeight = series.marker.height / 2;
                        break;
                    }
                }
                if (isInverted) {
                    location.y = point.regions[0].y + (point.regions[0].height / 2);
                }
                else {
                    location.x = point.regions[0].x + (point.regions[0].width / 2);
                }
            }
            else if (isInverted && series.type.indexOf('Stacking') > -1 && point.yValue === 0) {
                location = { x: labelRegion.x + labelRegion.width, y: labelRegion.y + (labelRegion.height) / 2 };
            }
            else if (labelIndex === 0 || labelIndex === 1) {
                location = new helper_1.ChartLocation(point.symbolLocations[0].x, point.symbolLocations[0].y);
            }
            else if ((labelIndex === 2 || labelIndex === 3) && series.type === 'Candle') {
                location = new helper_1.ChartLocation(point.symbolLocations[1].x, point.symbolLocations[1].y);
            }
            else Iif (isInverted) {
                location = { x: labelRegion.x + (labelRegion.width) / 2, y: labelRegion.y };
            }
            else {
                location = { x: labelRegion.x + labelRegion.width, y: labelRegion.y + (labelRegion.height) / 2 };
            }
            if (labelIndex > 1 && series.type === 'HiloOpenClose') {
                Iif (series.chart.requireInvertedAxis) {
                    var height = labelRegion.height;
                    location.y = labelRegion.y + height / 2 + 2 * (labelIndex === 2 ? 1 : -1);
                }
                else {
                    var width = labelRegion.width;
                    location.x = labelRegion.x + width / 2 + 2 * (labelIndex === 2 ? 1 : -1);
                }
            }
            return location;
        };
        DataLabel.prototype.calculateRectPosition = function (labelLocation, rect, isMinus, position, series, textSize, labelIndex, point) {
            if (series.chart.chartAreaType === 'PolarRadar') {
                return null;
            }
            var padding = 5;
            var margin = this.margin;
            var textLength = (series.marker.dataLabel.enableRotation ? textSize.width :
                (!this.inverted ? textSize.height : textSize.width));
            this.extraSpace = this.borderWidth + textLength / 2 + (position !== 'Outer' && series.type.indexOf('Column') > -1 &&
                (Math.abs(rect.height - textSize.height) < padding) ? 0 : padding);
            if (series.type === 'StackingColumn100' || series.type === 'StackingBar100') {
                position = (position === 'Outer') ? 'Top' : position;
            }
            else if (series.type.indexOf('Range') > -1) {
                position = (position === 'Outer' || position === 'Top') ? position : 'Auto';
            }
            else if (series.type === 'Waterfall') {
                position = position === 'Auto' ? 'Middle' : position;
            }
            switch (position) {
                case 'Bottom':
                    labelLocation = !this.inverted ?
                        isMinus ? (labelLocation + (series.type === 'Waterfall' ? (-this.extraSpace - margin.top - this.markerHeight) : (-rect.height + this.extraSpace + margin.top))) :
                            (labelLocation + rect.height - this.extraSpace - margin.bottom) :
                        isMinus ? (labelLocation + (series.type === 'Waterfall' ? (+this.extraSpace + margin.left + this.markerHeight) : (+rect.width - this.extraSpace - margin.left))) :
                            (labelLocation - rect.width + this.extraSpace + margin.right);
                    break;
                case 'Middle':
                    labelLocation = labelLocation = !this.inverted ?
                        (isMinus ? labelLocation - (rect.height / 2) : labelLocation + (rect.height / 2)) :
                        (isMinus ? labelLocation + (rect.width / 2) : labelLocation - (rect.width / 2));
                    break;
                case 'Auto':
                    labelLocation = this.calculateRectActualPosition(labelLocation, rect, isMinus, series, textSize, labelIndex, point);
                    break;
                default:
                    this.extraSpace += this.errorHeight;
                    labelLocation = this.calculateTopAndOuterPosition(labelLocation, rect, position, series, labelIndex, this.extraSpace, isMinus, point);
                    break;
            }
            var check = !this.inverted ? (labelLocation < rect.y || labelLocation > rect.y + rect.height) :
                (labelLocation < rect.x || labelLocation > rect.x + rect.width);
            this.fontBackground = check ?
                (this.fontBackground === 'transparent' ? this.chartBackground : this.fontBackground)
                : this.fontBackground === 'transparent' ? (point.color || series.interior) : this.fontBackground;
            var seriesLength = series.chart.series.length;
            if (position === 'Outer' && (series.type.indexOf('Stacking') > -1) && ((seriesLength - 1) > series.index)) {
                var nextSeries = void 0;
                var nextSeriesPoint = void 0;
                for (var i = series.index + 1; i < seriesLength; i++) {
                    nextSeries = series.chart.series[i];
                    nextSeriesPoint = nextSeries.points[point.index];
                    Eif ((nextSeries.type.indexOf('Stacking') > -1) && (nextSeries.type.indexOf('100') === -1)) {
                        this.fontBackground = (nextSeriesPoint && ((nextSeriesPoint.yValue < 0 && point.yValue < 0) ||
                            (nextSeriesPoint.yValue > 0 && point.yValue > 0))) ? (nextSeriesPoint ? nextSeriesPoint.color :
                            nextSeries.interior) : this.fontBackground;
                        break;
                    }
                }
            }
            return labelLocation;
        };
        DataLabel.prototype.calculatePathPosition = function (labelLocation, position, series, point, size, labelIndex) {
            var padding = 5;
            if ((series.type.indexOf('Area') > -1 && series.type !== 'RangeArea' && series.type !== 'SplineRangeArea' && series.type !== 'RangeStepArea')
                && this.yAxisInversed && series.marker.dataLabel.position !== 'Auto') {
                position = position === 'Top' ? 'Bottom' : position === 'Bottom' ? 'Top' : position;
            }
            this.fontBackground = this.fontBackground === 'transparent' ? this.chartBackground : this.fontBackground;
            switch (position) {
                case 'Top':
                case 'Outer':
                    labelLocation = labelLocation - this.markerHeight - this.borderWidth - size.height / 2 - this.margin.bottom - padding -
                        this.errorHeight;
                    break;
                case 'Bottom':
                    labelLocation = labelLocation + this.markerHeight + this.borderWidth + size.height / 2 + this.margin.top + padding +
                        this.errorHeight;
                    break;
                case 'Auto':
                    labelLocation = this.calculatePathActualPosition(labelLocation, this.markerHeight, series, point, size, labelIndex);
                    break;
            }
            return labelLocation;
        };
        DataLabel.prototype.isDataLabelShape = function (style) {
            this.isShape = (style.color !== 'transparent' || style.border.width > 0);
            this.borderWidth = style.border.width;
            if (!this.isShape) {
                this.margin = { left: 0, right: 0, bottom: 0, top: 0 };
            }
        };
        DataLabel.prototype.calculateRectActualPosition = function (labelLocation, rect, isMinus, series, size, labelIndex, point) {
            var location;
            var labelRect;
            var isOverLap = true;
            var position = 0;
            var collection = this.chart.dataLabelCollections;
            var finalPosition = series.type.indexOf('Range') !== -1 || series.type === 'Hilo' ? 2 : 4;
            while (isOverLap && position < finalPosition) {
                var actualPosition = this.getPosition(position);
                this.fontBackground = series.marker.dataLabel.fill;
                if (series.type.indexOf('Stacking') > -1 && actualPosition === 'Outer') {
                    actualPosition = 'Top';
                    position++;
                }
                location = this.calculateRectPosition(labelLocation, rect, isMinus, actualPosition, series, size, labelIndex, point);
                if (!this.inverted) {
                    Iif (series.marker.dataLabel.enableRotation) {
                        size.width = size.width - point.regions[0].width / 10;
                    }
                    labelRect = helper_3.calculateRect(new helper_1.ChartLocation(this.locationX, location), size, this.margin);
                    isOverLap = labelRect.y < 0 || helper_1.isCollide(labelRect, collection, series.clipRect) || labelRect.y > series.clipRect.height;
                    if (series.marker.dataLabel.template === null && isOverLap !== true) {
                        isOverLap = labelRect.y / 2 + size.height + (actualPosition === 'Outer' ? point.regions[0].height + this.extraSpace : point.regions[0].height - 2 * this.extraSpace) > series.clipRect.height;
                    }
                }
                else {
                    labelRect = helper_3.calculateRect(new helper_1.ChartLocation(location, this.locationY), size, this.margin);
                    isOverLap = labelRect.x < 0 || helper_1.isCollide(labelRect, collection, series.clipRect) ||
                        labelRect.x + labelRect.width > series.clipRect.width;
                }
                position++;
            }
            return location;
        };
        DataLabel.prototype.calculateAlignment = function (value, labelLocation, alignment, isMinus) {
            switch (alignment) {
                case 'Far':
                    labelLocation = !this.inverted ? (isMinus ? labelLocation + value : labelLocation - value) :
                        (isMinus ? labelLocation - value : labelLocation + value);
                    break;
                case 'Near':
                    labelLocation = !this.inverted ? (isMinus ? labelLocation - value : labelLocation + value) :
                        (isMinus ? labelLocation + value : labelLocation - value);
                    break;
            }
            return labelLocation;
        };
        DataLabel.prototype.calculateTopAndOuterPosition = function (location, rect, position, series, index, extraSpace, isMinus, point) {
            var margin = this.margin;
            var top;
            switch (series.type) {
                case 'RangeColumn':
                case 'RangeArea':
                case 'RangeStepArea':
                case 'SplineRangeArea':
                case 'Hilo':
                    top = (index === 0 && !this.yAxisInversed) || (index === 1 && this.yAxisInversed);
                    location = this.updateLabelLocation(position, location, extraSpace, margin, rect, top);
                    break;
                case 'Candle':
                    top = (index === 0 || index === 2) && !this.yAxisInversed
                        || (index === 1 || index === 3) && this.yAxisInversed;
                    location = this.updateLabelLocation(position, location, extraSpace, margin, rect, top, index > 1);
                    break;
                case 'HiloOpenClose':
                    if (index <= 1) {
                        top = (index === 0 && !this.yAxisInversed) || (index === 1 && this.yAxisInversed);
                        location = this.updateLabelLocation(position, location, extraSpace, margin, rect, top);
                    }
                    else {
                        Iif (this.yAxisInversed) {
                            location = !this.inverted ? location + extraSpace + margin.top : location - extraSpace - margin.right;
                        }
                        else {
                            location = !this.inverted ? location - extraSpace - margin.bottom : location + extraSpace + margin.left;
                        }
                    }
                    break;
                default:
                    if (((isMinus && position === 'Top') || (!isMinus && position === 'Outer')) || (position === 'Top' && series.visiblePoints[point.index].yValue === 0)) {
                        location = !this.inverted ? location + (isMinus && series.type === 'Waterfall' ? (-rect.height + extraSpace + margin.bottom) : (-extraSpace - margin.bottom - this.markerHeight)) :
                            location + (isMinus && series.type === 'Waterfall' ? (+rect.width - extraSpace - margin.left) : (+extraSpace + margin.left + this.markerHeight));
                    }
                    else {
                        location = !this.inverted ? location + (isMinus && series.type === 'Waterfall' ? (-rect.height - extraSpace - margin.top) : (+extraSpace + margin.top + this.markerHeight)) :
                            location + (isMinus && series.type === 'Waterfall' ? (+rect.width + extraSpace + margin.top) : (-extraSpace - margin.right - this.markerHeight));
                    }
                    break;
            }
            return location;
        };
        DataLabel.prototype.updateLabelLocation = function (position, location, extraSpace, margin, rect, top, inside) {
            if (inside === void 0) { inside = false; }
            if (!this.inverted) {
                if (top) {
                    location = (position === 'Outer' && !inside) ? location - extraSpace - margin.bottom - this.markerHeight :
                        location + extraSpace + margin.top + this.markerHeight;
                }
                else {
                    location = (position === 'Outer' && !inside) ? location + rect.height + extraSpace + margin.top + this.markerHeight :
                        location + rect.height - extraSpace - margin.bottom - this.markerHeight;
                }
            }
            else {
                if (top) {
                    location = (position === 'Outer' && !inside) ? location + extraSpace + margin.left + this.markerHeight :
                        location - extraSpace - margin.right - this.markerHeight;
                }
                else {
                    location = (position === 'Outer' && !inside) ? location - rect.width - extraSpace - margin.right - this.markerHeight :
                        location - rect.width + extraSpace + margin.left + this.markerHeight;
                }
            }
            return location;
        };
        DataLabel.prototype.calculatePathActualPosition = function (y, markerSize, series, point, size, labelIndex) {
            var points = series.points;
            var index = point.index;
            var yValue = points[index].yValue;
            var position;
            var nextPoint = points.length - 1 > index ? points[index + 1] : null;
            var previousPoint = index > 0 ? points[index - 1] : null;
            var yLocation;
            var isOverLap = true;
            var labelRect;
            var isBottom;
            var positionIndex;
            var collection = this.chart.dataLabelCollections;
            if (series.type === 'Bubble') {
                position = 'Top';
            }
            else if (series.type.indexOf('Step') > -1) {
                position = 'Top';
                if (index) {
                    position = (!previousPoint || !previousPoint.visible || (yValue > previousPoint.yValue !== this.yAxisInversed)
                        || yValue === previousPoint.yValue) ? 'Top' : 'Bottom';
                }
            }
            else if (series.type === 'BoxAndWhisker') {
                if (labelIndex === 1 || labelIndex === 3 || labelIndex > 4) {
                    position = series.yAxis.isAxisInverse ? 'Bottom' : 'Top';
                }
                else if (labelIndex === 2 || labelIndex === 4) {
                    position = series.yAxis.isAxisInverse ? 'Top' : 'Bottom';
                }
                else {
                    isOverLap = false;
                    position = 'Middle';
                    yLocation = this.calculatePathPosition(y, position, series, point, size, labelIndex);
                }
            }
            else {
                if (index === 0) {
                    position = (!nextPoint || !nextPoint.visible || yValue > nextPoint.yValue ||
                        (yValue < nextPoint.yValue && this.yAxisInversed)) ? 'Top' : 'Bottom';
                }
                else if (index === points.length - 1) {
                    position = (!previousPoint || !previousPoint.visible || yValue > previousPoint.yValue ||
                        (yValue < previousPoint.yValue && this.yAxisInversed)) ? 'Top' : 'Bottom';
                }
                else {
                    if (!nextPoint.visible && !(previousPoint && previousPoint.visible)) {
                        position = 'Top';
                    }
                    else if (!nextPoint.visible || !previousPoint) {
                        position = (nextPoint.yValue > yValue || (previousPoint && previousPoint.yValue > yValue)) ?
                            'Bottom' : 'Top';
                    }
                    else {
                        var slope = (nextPoint.yValue - previousPoint.yValue) / 2;
                        var intersectY = (slope * index) + (nextPoint.yValue - (slope * (index + 1)));
                        position = !this.yAxisInversed ? intersectY < yValue ? 'Top' : 'Bottom' :
                            intersectY < yValue ? 'Bottom' : 'Top';
                    }
                }
            }
            isBottom = position === 'Bottom';
            positionIndex = ['Outer', 'Top', 'Bottom', 'Middle', 'Auto'].indexOf(position);
            while (isOverLap && positionIndex < 4) {
                yLocation = this.calculatePathPosition(y, this.getPosition(positionIndex), series, point, size, labelIndex);
                labelRect = helper_3.calculateRect(new helper_1.ChartLocation(this.locationX, yLocation), size, this.margin);
                isOverLap = labelRect.y < 0 || helper_1.isCollide(labelRect, collection, series.clipRect)
                    || (labelRect.y + labelRect.height) > series.clipRect.height;
                positionIndex = isBottom ? positionIndex - 1 : positionIndex + 1;
                isBottom = false;
            }
            return yLocation;
        };
        DataLabel.prototype.doDataLabelAnimation = function (series, element) {
            var shapeElements = series.shapeElement.childNodes;
            var textNode = series.textElement.childNodes;
            var delay = series.animation.delay + series.animation.duration;
            var duration = series.chart.animated ? series.chart.duration : 200;
            var location;
            var length = element ? 1 : textNode.length;
            var tempElement;
            for (var i = 0; i < length; i++) {
                tempElement = textNode[i];
                if (element) {
                    element.style.visibility = 'hidden';
                    helper_4.templateAnimate(element, delay, duration, 'ZoomIn');
                }
                else {
                    location = new helper_1.ChartLocation((+tempElement.getAttribute('x')) + ((+tempElement.getAttribute('width')) / 2), (+tempElement.getAttribute('y')) + ((+tempElement.getAttribute('height')) / 2));
                    helper_2.markerAnimate(tempElement, delay, duration, series, null, location, true);
                    if (shapeElements[i]) {
                        tempElement = shapeElements[i];
                        location = new helper_1.ChartLocation((+tempElement.getAttribute('x')) + ((+tempElement.getAttribute('width')) / 2), (+tempElement.getAttribute('y')) + ((+tempElement.getAttribute('height')) / 2));
                        helper_2.markerAnimate(tempElement, delay, duration, series, null, location, true);
                    }
                }
            }
        };
        DataLabel.prototype.getPosition = function (index) {
            return (['Outer', 'Top', 'Bottom', 'Middle', 'Auto'][index]);
        };
        DataLabel.prototype.getModuleName = function () {
            return 'DataLabel';
        };
        DataLabel.prototype.destroy = function () {
        };
        return DataLabel;
    }());
    exports.DataLabel = DataLabel;
});