all files / accumulation-chart/renderer/ dataLabel.js

94.52% Statements 655/693
89.5% Branches 622/695
100% Functions 65/65
94.71% Lines 645/681
11 statements, 6 functions, 9 branches Ignored     
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 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028          289× 289× 289× 289× 289×   2608×     2608× 504× 504×   2608× 2608× 2608× 2608× 2292×     25009× 25009× 25009× 25009×   25009× 25009× 25009× 25009× 23503× 23503× 12632×     10871×       2806× 167×   2639× 2639×     2639×     2639×   2639× 2639× 2639× 2589× 1251×         1338×     2639× 10×   2629× 2519×   110× 70×     40×     2639× 2639× 2639× 2639× 2639× 2686× 2686× 2686×   2639×     2639×   2292× 2292× 2292×   2292× 2292× 2292× 1431× 1431× 1431×     198× 198× 115×   198× 198× 198× 198× 198× 198× 198×   72×         861×   191×     2292× 12× 12× 12× 12× 12×   12× 12× 12× 12×         25× 25×           22×   25×     2490× 2490× 2647× 2647× 2079×     411×   6521× 26990×     334×     6187×   4716× 2547× 2547× 60×   2487× 17× 17× 17× 17×     2470× 1417×   1053× 1036× 1036× 101×     17× 17×   2547× 2530×     2530× 242× 235×     242×   2530× 2378× 52× 52×           126× 126×   30×   271× 99×     172× 172× 172× 61×   172× 172×   13327× 118×   13209× 13209× 13209×       99× 99×     99× 99×     1143× 1143×   1143× 1143× 1143× 1143× 1143× 1143× 1143×       3110×           3110× 3110× 3110× 3110× 3110× 11697× 456×     2654×   11697× 11697× 11697× 11697× 11697× 11697× 11697× 11697× 10649× 10649× 10649× 10649× 10649× 10649× 10649×   1048×   172× 172× 83× 83×     89×   172×   1180× 1180× 1180×     1180× 1180× 1180× 1180× 1180× 206× 201×   201× 121×     80× 80×     201×           974×       17× 17× 17× 17× 16×       51× 34×   17× 17× 17× 17× 17× 17× 17× 17× 17× 17×           3466× 3466× 3466× 3466× 1313× 1313× 1313× 1313×   2153× 20× 20× 20× 20×     2133× 2133× 2133× 2133×   3466×   2189× 432× 432× 432×     1757× 1757× 1757× 1757× 1757×   934×   823× 823×     3944× 3944× 1978× 1978×       1978×   620× 620×   1334× 1334×   24×   1978×     1966×       1180× 1180× 12×   1180×     323× 323× 323×   2608× 2608× 2608× 2608× 2608× 2608×         2608× 2608× 2608× 2608× 2608× 2608× 2608× 2608×         2608×   2608× 1167× 1167×       1167×   2608×   2608× 2608×   2608× 2608× 2608× 2608× 2608× 2608× 2608×     323× 323× 323× 4671× 323× 197×   323× 2623× 2623× 2617× 2617× 2617× 2617× 2617× 2617× 2617× 2617× 2482× 2482× 167×     2315×   2315× 2315× 2315× 2315× 194× 184× 104×   80× 33×     47×       10×       2121×   2315× 2315× 2315× 2315× 2315× 2315×   2482×   2017×   2482× 1180× 1180× 1180× 1180×   2482×   135× 10×       323×                       2617×   102× 10×     2617×   2227× 2227×       2227× 2227×   2617× 2489×   2489×   2617×     47×     167× 167× 167×   167× 167× 167× 167×                   167× 157× 157×     2234× 2234× 2234×         2234× 2234× 2234× 2234×   157× 157× 157× 87× 87×     2017×     2608× 2608× 2608× 2608× 2608× 2608× 2608×   3272×     197× 197× 197× 840× 840× 840×   197× 926× 926× 926×   197× 197× 197×   201× 201× 898× 201× 201× 201× 201× 201× 201× 85×         201× 405× 405× 405×   61× 61× 61× 13×   48×   61× 57× 307×       52×         344×         197× 926× 197× 197× 197× 197× 197× 197× 380× 380× 380×   43× 43×     43× 43× 283× 283× 3041× 21×                       337×           335×     335× 335× 52×   628× 628×   628× 13× 13× 13×   615× 615×       283×   283×   2614× 2614×   2606× 2606×           2606×       307×     307× 307× 307×   5594× 5594×         5594× 5594×     5590×     5590×                                       8822× 8822× 8822×     8822×       8822× 8822× 8822× 8822×   380× 1039×       40×     340×   405× 1517×     61×     344×   1766×   168× 168× 168× 168× 21×     1598×   233× 233× 233× 233× 233× 233×       121× 121× 121× 121× 42×   79× 34×   45×       45×   121×        
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-svg-base", "../../common/utils/helper", "../../common/utils/helper", "../../common/utils/helper", "../../common/utils/helper", "../model/acc-base", "../../common/model/constants", "../../common/utils/helper", "./accumulation-base"], function (require, exports, ej2_base_1, ej2_svg_base_1, helper_1, helper_2, helper_3, helper_4, acc_base_1, constants_1, helper_5, accumulation_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AccumulationDataLabel = (function (_super) {
        __extends(AccumulationDataLabel, _super);
        function AccumulationDataLabel(accumulation) {
            var _this = _super.call(this, accumulation) || this;
            _this.rightSideRenderingPoints = [];
            _this.leftSideRenderingPoints = [];
            _this.id = accumulation.element.id + '_datalabel_Series_';
            return _this;
        }
        AccumulationDataLabel.prototype.getDataLabelPosition = function (point, dataLabel, textSize, points) {
            var radius = this.isCircular() ? (!this.isVariousRadius() ? this.accumulation.pieSeriesModule.labelRadius :
                this.accumulation.pieSeriesModule.getLabelRadius(this.accumulation.visibleSeries[0], point)) :
                this.getLabelDistance(point, dataLabel);
            if (this.accumulation.title) {
                var titleSize = ej2_svg_base_1.measureText(this.accumulation.title, this.accumulation.titleStyle, this.accumulation.themeStyle.datalabelFont);
                this.titleRect = new ej2_svg_base_1.Rect(this.accumulation.availableSize.width / 2 - titleSize.width / 2, this.accumulation.margin.top, titleSize.width, titleSize.height);
            }
            this.getLabelRegion(point, dataLabel.position, textSize, radius, this.marginValue);
            point.labelAngle = point.midAngle;
            point.labelPosition = dataLabel.position;
            if (this.accumulation.enableSmartLabels) {
                this.getSmartLabel(point, dataLabel, textSize, points);
            }
        };
        AccumulationDataLabel.prototype.getLabelRegion = function (point, position, textSize, labelRadius, margin, endAngle) {
            if (endAngle === void 0) { endAngle = 0; }
            var labelAngle = endAngle || point.midAngle;
            var space = 20;
            var location = helper_1.degreeToLocation(labelAngle, labelRadius, this.isCircular() ? this.center :
                this.getLabelLocation(point, position));
            location.y = (position === 'Inside') ? (location.y - textSize.height / 2) : location.y;
            location.x = (position === 'Inside') ? (location.x - textSize.width / 2) : location.x;
            point.labelRegion = new ej2_svg_base_1.Rect(location.x, location.y, textSize.width + (margin * 2), textSize.height + (margin * 2));
            if (position === 'Outside') {
                point.labelRegion.y -= point.labelRegion.height / 2;
                if (labelAngle >= 90 && labelAngle <= 270) {
                    point.labelRegion.x -= (point.labelRegion.width + space);
                }
                else {
                    point.labelRegion.x += space;
                }
            }
        };
        AccumulationDataLabel.prototype.calculateLabelCollection = function (point, dataLabel) {
            if (point.argsData.template !== null) {
                return null;
            }
            var position = point.labelPosition || dataLabel.position;
            var labelRadius = this.isCircular() ? (!this.isVariousRadius() ? this.accumulation.pieSeriesModule.labelRadius :
                this.accumulation.pieSeriesModule.getLabelRadius(this.accumulation.visibleSeries[0], point)) :
                this.getLabelDistance(point, dataLabel);
            var radius = (!this.isVariousRadius() ?
                (this.accumulation.pieSeriesModule.radius - this.accumulation.pieSeriesModule.innerRadius) :
                this.accumulation.pieSeriesModule.getLabelRadius(this.accumulation.visibleSeries[0], point));
            var location = helper_1.degreeToLocation(point.midAngle, labelRadius, this.isCircular() ? this.center :
                this.getLabelLocation(point, position));
            var padding = 20;
            var maxWidth = dataLabel.maxWidth;
            if (!maxWidth) {
                if (position === 'Outside') {
                    maxWidth = this.isCircular() ? (location.x >= this.center.x) ? (this.areaRect.x + this.areaRect.width - location.x) :
                        (location.x - this.areaRect.x) : (location.x >= point.region.x) ?
                        (this.areaRect.x + this.areaRect.width - location.x) : (location.x - this.areaRect.x);
                }
                else {
                    maxWidth = this.isCircular() ? (radius - padding) : point.region.width;
                }
            }
            if ((point.label.indexOf('<br>') !== -1)) {
                point.labelCollection = point.label.split('<br>');
            }
            else if (dataLabel.textWrap === 'Normal' && dataLabel.textOverflow === 'Ellipsis') {
                point.labelCollection[0] = helper_2.textTrim(maxWidth, point.label, point.argsData.font, this.accumulation.enableRtl, this.accumulation.themeStyle.datalabelFont);
            }
            else if (dataLabel.textWrap === 'Wrap' || dataLabel.textWrap === 'AnyWhere') {
                point.labelCollection = helper_4.textWrap(point.label, maxWidth, point.argsData.font, this.accumulation.enableRtl, dataLabel.textWrap === 'AnyWhere', dataLabel.textOverflow === 'Clip', this.accumulation.themeStyle.datalabelFont);
            }
            else {
                point.labelCollection[0] = point.label;
            }
        };
        AccumulationDataLabel.prototype.getTextSize = function (labelCollection, dataLabel) {
            var height = 0;
            var font = dataLabel.font;
            var width = dataLabel.maxWidth ? dataLabel.maxWidth : 0;
            var textSize;
            for (var i = 0; i < labelCollection.length; i++) {
                textSize = ej2_svg_base_1.measureText(labelCollection[i], font, this.accumulation.themeStyle.datalabelFont);
                width = Math.max(textSize.width, width);
                height += textSize.height;
            }
            Iif (dataLabel.textOverflow === 'Clip' && dataLabel.textWrap !== 'Normal' && dataLabel.maxWidth) {
                width = dataLabel.maxWidth;
            }
            return (new ej2_svg_base_1.Size(width, height));
        };
        AccumulationDataLabel.prototype.getSmartLabel = function (point, dataLabel, textSize, points) {
            var circular = this.isCircular();
            var labelRadius = circular ? this.radius : this.getLabelDistance(point, dataLabel);
            var connectorLength = circular ? (dataLabel.connectorStyle.length || '4%') :
                '0px';
            labelRadius += helper_1.stringToNumber(connectorLength, labelRadius);
            var previousPoint = this.findPreviousPoint(points, point.index, point.labelPosition);
            if (dataLabel.position === 'Inside') {
                point.labelRegion.height -= 4;
                point.labelRegion.width -= 4;
                if (previousPoint && previousPoint.labelRegion && !dataLabel.enableRotation &&
                    (helper_1.isOverlap(point.labelRegion, previousPoint.labelRegion)
                        || this.isOverlapping(point, points)) || !circular && !helper_4.containsRect(point.region, point.labelRegion)) {
                    point.labelPosition = 'Outside';
                    if (!circular) {
                        labelRadius = this.getLabelDistance(point, dataLabel);
                    }
                    this.calculateLabelCollection(point, dataLabel);
                    textSize = this.getTextSize(point.labelCollection, dataLabel);
                    textSize.height += 4;
                    textSize.width += 4;
                    this.getLabelRegion(point, point.labelPosition, textSize, labelRadius, this.marginValue);
                    previousPoint = this.findPreviousPoint(points, point.index, point.labelPosition);
                    if (previousPoint && (helper_1.isOverlap(point.labelRegion, previousPoint.labelRegion) ||
                        this.isConnectorLineOverlapping(point, previousPoint))) {
                        this.setOuterSmartLabel(previousPoint, point, dataLabel.border.width, labelRadius, textSize, this.marginValue);
                    }
                }
            }
            else {
                if (previousPoint && previousPoint.labelRegion && (helper_1.isOverlap(point.labelRegion, previousPoint.labelRegion)
                    || this.isOverlapping(point, points) || this.isConnectorLineOverlapping(point, previousPoint))) {
                    this.setOuterSmartLabel(previousPoint, point, dataLabel.border.width, labelRadius, textSize, this.marginValue);
                }
            }
            if (this.isOverlapping(point, points) && (this.accumulation.type === 'Pyramid' || this.accumulation.type === 'Funnel')) {
                var position = 'OutsideLeft';
                var space = 20;
                var labelAngle = point.midAngle || 0;
                var labelRadius_1 = circular ? this.radius : this.getLabelDistance(point, dataLabel);
                var location_1 = helper_1.degreeToLocation(labelAngle, -labelRadius_1, this.isCircular() ? this.center :
                    this.getLabelLocation(point, position));
                point.labelRegion = new ej2_svg_base_1.Rect(location_1.x, location_1.y, textSize.width + (this.marginValue * 2), textSize.height + (this.marginValue * 2));
                point.labelRegion.y -= point.labelRegion.height / 2;
                point.labelRegion.x = point.labelRegion.x - space - point.labelRegion.width;
                if (previousPoint && previousPoint.labelRegion && (helper_1.isOverlap(point.labelRegion, previousPoint.labelRegion)
                    || this.isOverlapping(point, points) || this.isConnectorLineOverlapping(point, previousPoint))) {
                    this.setOuterSmartLabel(previousPoint, point, dataLabel.border.width, labelRadius_1, textSize, this.marginValue);
                }
            }
        };
        AccumulationDataLabel.prototype.move = function (e, x, y, isTouch) {
            var _this = this;
            if (e.target.textContent.indexOf('...') > -1) {
                var targetId = e.target.id.split(this.id);
                Eif (targetId.length === 2) {
                    var seriesIndex = parseInt(targetId[1].split('_text_')[0], 10);
                    var pointIndex = parseInt(targetId[1].split('_text_')[1], 10);
                    Eif (!isNaN(seriesIndex) && !isNaN(pointIndex)) {
                        if (isTouch) {
                            helper_3.removeElement(this.accumulation.element.id + '_EJ2_Datalabel_Tooltip');
                        }
                        var point = acc_base_1.getSeriesFromIndex(seriesIndex, (this.accumulation).visibleSeries).points[pointIndex];
                        helper_3.showTooltip(point.text || point.y.toString(), x, y, this.areaRect.width, this.accumulation.element.id + '_EJ2_Datalabel_Tooltip', helper_2.getElement(this.accumulation.element.id + '_Secondary_Element'), null, null, this.accumulation.initialClipRect);
                    }
                }
            }
            else {
                helper_3.removeElement(this.accumulation.element.id + '_EJ2_Datalabel_Tooltip');
            }
            if (isTouch) {
                clearTimeout(this.clearTooltip);
                this.clearTooltip = +setTimeout(function () { helper_3.removeElement(_this.accumulation.element.id + '_EJ2_Datalabel_Tooltip'); }, 1000);
            }
        };
        AccumulationDataLabel.prototype.findPreviousPoint = function (points, index, position) {
            var point = points[0];
            for (var i = index - 1; i >= 0; i--) {
                point = points[i];
                if (point.visible && point.labelVisible && point.labelRegion && point.labelPosition === position) {
                    return point;
                }
            }
            return null;
        };
        AccumulationDataLabel.prototype.isOverlapping = function (currentPoint, points) {
            for (var i = currentPoint.index - 1; i >= 0; i--) {
                if (points[i].visible && points[i].labelVisible &&
                    points[i].labelRegion && currentPoint.labelRegion &&
                    currentPoint.labelVisible && helper_1.isOverlap(currentPoint.labelRegion, points[i].labelRegion)) {
                    return true;
                }
            }
            return false;
        };
        AccumulationDataLabel.prototype.textTrimming = function (point, rect, font, position, dataLabel) {
            if (helper_1.isOverlap(point.labelRegion, rect)) {
                var size = point.labelRegion.width;
                if (position === 'Right') {
                    size = rect.x - point.labelRegion.x;
                }
                else if (position === 'Left') {
                    size = point.labelRegion.x - (rect.x + rect.width);
                    Eif (size < 0) {
                        size += point.labelRegion.width;
                        point.labelRegion.x = rect.x + rect.width;
                    }
                }
                else if (position === 'InsideRight') {
                    size = (rect.x + rect.width) - point.labelRegion.x;
                }
                else if (position === 'InsideLeft') {
                    size = (point.labelRegion.x + point.labelRegion.width) - rect.x;
                    if (size < point.labelRegion.width) {
                        point.labelRegion.x = rect.x;
                    }
                }
                else Eif (this.accumulation.enableSmartLabels) {
                    this.setPointVisibileFalse(point);
                }
                if (point.labelVisible && point.labelRegion) {
                    Iif ((point.label.indexOf('<br>') !== -1)) {
                        point.labelCollection = point.label.split('<br>');
                    }
                    else if (size < point.labelRegion.width) {
                        if (dataLabel.textWrap === 'Normal' && dataLabel.textOverflow === 'Ellipsis') {
                            point.labelCollection[0] = helper_2.textTrim(size - (this.marginValue * 2), point.label, font, this.accumulation.enableRtl, this.accumulation.themeStyle.datalabelFont);
                        }
                        else Eif (dataLabel.textWrap === 'Wrap' || dataLabel.textWrap === 'AnyWhere') {
                            point.labelCollection = helper_4.textWrap(point.label, size - (this.marginValue * 2), font, this.accumulation.enableRtl, dataLabel.textWrap === 'AnyWhere', dataLabel.textOverflow === 'Clip', this.accumulation.themeStyle.datalabelFont);
                        }
                        point.labelRegion.width = size;
                    }
                    for (var i = 0; i < point.labelCollection.length; i++) {
                        if (point.labelCollection[i].length === 3 && point.labelCollection[i].indexOf('...') > -1) {
                            this.setPointVisibileFalse(point);
                            break;
                        }
                    }
                }
            }
        };
        AccumulationDataLabel.prototype.setPointVisibileFalse = function (point) {
            point.labelVisible = false;
            point.labelRegion = null;
        };
        AccumulationDataLabel.prototype.setPointVisibleTrue = function (point) {
            point.labelVisible = true;
        };
        AccumulationDataLabel.prototype.setOuterSmartLabel = function (previousPoint, point, border, labelRadius, textsize, margin) {
            if (!this.isCircular()) {
                this.setSmartLabelForSegments(point, previousPoint);
            }
            else {
                var labelAngle = this.getOverlappedAngle(previousPoint.labelRegion, point.labelRegion, point.midAngle, border * 2);
                this.getLabelRegion(point, 'Outside', textsize, labelRadius, margin, labelAngle);
                if (labelAngle > point.endAngle) {
                    labelAngle = point.midAngle;
                }
                point.labelAngle = labelAngle;
                while (point.labelVisible && (helper_1.isOverlap(previousPoint.labelRegion, point.labelRegion) || labelAngle <= previousPoint.labelAngle
                    || labelAngle <= point.midAngle * 0.9 || this.isConnectorLineOverlapping(point, previousPoint))) {
                    if (labelAngle > point.endAngle) {
                        break;
                    }
                    point.labelAngle = labelAngle;
                    this.getLabelRegion(point, 'Outside', textsize, labelRadius, margin, labelAngle);
                    labelAngle += 0.1;
                }
            }
        };
        AccumulationDataLabel.prototype.setSmartLabelForSegments = function (point, prevPoint) {
            var textRegion = point.labelRegion;
            var overlapHeight = this.accumulation.type === 'Funnel' ?
                prevPoint.labelRegion.y - (textRegion.y + textRegion.height) :
                point.labelRegion.y - (prevPoint.labelRegion.y + prevPoint.labelRegion.height);
            Eif (overlapHeight < 0) {
                point.labelRegion.y += this.accumulation.type === 'Funnel' ? overlapHeight : -overlapHeight;
            }
        };
        AccumulationDataLabel.prototype.isConnectorLineOverlapping = function (point, previous) {
            var position;
            if (!this.isCircular() && point.labelRegion.x < point.region.x) {
                position = 'outsideLeft';
            }
            var start = this.getLabelLocation(point, position);
            var end = new helper_1.ChartLocation(0, 0);
            this.getEdgeOfLabel(point.labelRegion, point.labelAngle, end, 0, point);
            var previousstart = this.getLabelLocation(previous);
            var previousend = new helper_1.ChartLocation(0, 0);
            this.getEdgeOfLabel(previous.labelRegion, previous.labelAngle, previousend, 0, point);
            return this.isLineRectangleIntersect(start, end, point.labelRegion) ||
                this.isLineRectangleIntersect(start, end, previous.labelRegion) ||
                this.isLineRectangleIntersect(previousstart, previousend, point.labelRegion);
        };
        AccumulationDataLabel.prototype.isLineRectangleIntersect = function (line1, line2, rect) {
            var rectPoints = [
                new helper_1.ChartLocation(Math.round(rect.x), Math.round(rect.y)),
                new helper_1.ChartLocation(Math.round((rect.x + rect.width)), Math.round(rect.y)),
                new helper_1.ChartLocation(Math.round((rect.x + rect.width)), Math.round((rect.y + rect.height))),
                new helper_1.ChartLocation(Math.round(rect.x), Math.round((rect.y + rect.height)))
            ];
            line1.x = Math.round(line1.x);
            line1.y = Math.round(line1.y);
            line2.x = Math.round(line2.x);
            line2.y = Math.round(line2.y);
            for (var i = 0; i < rectPoints.length; i++) {
                if (this.isLinesIntersect(line1, line2, rectPoints[i], rectPoints[(i + 1) % rectPoints.length])) {
                    return true;
                }
            }
            return false;
        };
        AccumulationDataLabel.prototype.isLinesIntersect = function (point1, point2, point11, point12) {
            var a1 = point2.y - point1.y;
            var b1 = point1.x - point2.x;
            var c1 = a1 * point1.x + b1 * point1.y;
            var a2 = point12.y - point11.y;
            var b2 = point11.x - point12.x;
            var c2 = a2 * point11.x + b2 * point11.y;
            var delta = a1 * b2 - a2 * b1;
            if (delta !== 0) {
                var x = (b2 * c1 - b1 * c2) / delta;
                var y = (a1 * c2 - a2 * c1) / delta;
                var lies = Math.min(point1.x, point2.x) <= x && x <= Math.max(point1.x, point2.x);
                lies = lies && Math.min(point1.y, point2.y) <= y && y <= Math.max(point1.y, point2.y);
                lies = lies && Math.min(point11.x, point12.x) <= x && x <= Math.max(point11.x, point12.x);
                lies = lies && Math.min(point11.y, point12.y) <= y && y <= Math.max(point11.y, point12.y);
                return lies;
            }
            return false;
        };
        AccumulationDataLabel.prototype.getOverlappedAngle = function (first, second, angle, padding) {
            var x = first.x;
            if (angle >= 90 && angle <= 270) {
                second.y = first.y - (padding + second.height / 2);
                x = first.x + first.width;
            }
            else {
                second.y = first.y + first.height + padding;
            }
            return helper_1.getAngle(this.center, new helper_1.ChartLocation(x, second.y));
        };
        AccumulationDataLabel.prototype.getConnectorPath = function (label, point, dataLabel, end) {
            Iif (end === void 0) { end = 0; }
            var connector = dataLabel.connectorStyle;
            var labelRadius = this.isCircular() ? (!this.isVariousRadius() ? this.labelRadius :
                this.accumulation.pieSeriesModule.getLabelRadius(this.accumulation.visibleSeries[0], point)) :
                this.getLabelDistance(point, dataLabel);
            var start = this.getConnectorStartPoint(point, connector);
            var labelAngle = this.accumulation.enableSmartLabels ? point.midAngle : end || point.midAngle;
            var middle = new helper_1.ChartLocation(0, 0);
            var endPoint = this.getEdgeOfLabel(label, labelAngle, middle, connector.width, point);
            if (connector.type === 'Curve') {
                if (this.isCircular()) {
                    var r = labelRadius - (this.isVariousRadius() ? helper_1.stringToNumber(point.sliceRadius, this.accumulation.pieSeriesModule.size / 2) :
                        this.radius);
                    if (point.isLabelUpdated) {
                        middle = this.getPerpendicularDistance(start, point);
                    }
                    else {
                        middle = helper_1.degreeToLocation(labelAngle, labelRadius - (r / 2), this.center);
                        if (point.labelPosition === 'Outside' && dataLabel.position === 'Inside') {
                            middle = helper_1.degreeToLocation(labelAngle, labelRadius - r * 1.25, this.center);
                        }
                    }
                    return 'M ' + start.x + ' ' + start.y + ' Q ' + middle.x + ' ' + middle.y + ' ' + endPoint.x + ' ' + endPoint.y;
                }
                else {
                    return this.getPolyLinePath(start, endPoint);
                }
            }
            else {
                return 'M ' + start.x + ' ' + start.y + ' L ' + middle.x + ' ' + middle.y + ' L ' + endPoint.x + ' ' + endPoint.y;
            }
        };
        AccumulationDataLabel.prototype.getPolyLinePath = function (start, end) {
            var controlPoints = [start, end];
            if (start.y === end.y) {
                return 'M ' + start.x + ' ' + start.y + ' L ' + end.x + ' ' + end.y;
            }
            var path = 'M';
            for (var i = 0; i <= 16; i++) {
                var t = i / 16;
                var points = this.getBezierPoint(t, controlPoints, 0, 2);
                path += points.x + ',' + points.y;
                if (i !== 16) {
                    path += ' L';
                }
            }
            return path;
        };
        AccumulationDataLabel.prototype.getBezierPoint = function (t, controlPoints, index, count) {
            if (count === 1) {
                return controlPoints[index];
            }
            var p0 = this.getBezierPoint(t, controlPoints, index, count - 1);
            var p1 = this.getBezierPoint(t, controlPoints, index + 1, count - 1);
            var x = (p0.x) ? p0.x : p0.x;
            var y = (p0.y) ? p0.y : p0.y;
            var x1 = (p1.x) ? p1.x : p1.x;
            var y1 = (p1.y) ? p1.y : p1.y;
            var x2 = (1 - t) * x + t * x1;
            var y2 = (1 - t) * y + t * y1;
            Eif (p0.x) {
                return { x: x2, y: y2 };
            }
            else {
                return { x: x2, y: y2 };
            }
        };
        AccumulationDataLabel.prototype.getEdgeOfLabel = function (labelshape, angle, middle, border, point) {
            Iif (border === void 0) { border = 1; }
            var edge = new helper_1.ChartLocation(labelshape.x, labelshape.y);
            var space = 10;
            if (angle >= 90 && angle <= 270) {
                edge.x += labelshape.width + border / 2 + space;
                edge.y += labelshape.height / 2;
                middle.x = edge.x + 10;
                middle.y = edge.y;
            }
            else if (point && point.region && point.region.x > point.labelRegion.x) {
                edge.x += border * 2 + labelshape.width + space;
                edge.y += labelshape.height / 2;
                middle.x = edge.x + 10;
                middle.y = edge.y;
            }
            else {
                edge.x -= space - border / 2;
                edge.y += labelshape.height / 2;
                middle.x = edge.x - 10;
                middle.y = edge.y;
            }
            return edge;
        };
        AccumulationDataLabel.prototype.getLabelDistance = function (point, dataLabel) {
            if (point.labelPosition && dataLabel.position !== point.labelPosition || (dataLabel.connectorStyle.length && dataLabel.position === 'Outside')) {
                var length_1 = helper_1.stringToNumber(dataLabel.connectorStyle.length || '70px', this.accumulation.initialClipRect.width);
                Eif (length_1 < this.accumulation.initialClipRect.width) {
                    return length_1;
                }
            }
            var position = point.labelPosition || dataLabel.position;
            var series = this.accumulation.visibleSeries[0];
            var extraSpace = (this.accumulation.initialClipRect.width - series.triangleSize.width) / 2;
            var labelLocation;
            switch (position) {
                case 'Inside':
                    return 0;
                case 'Outside':
                    labelLocation = point.symbolLocation.x + point.labelOffset.x;
                    return this.accumulation.initialClipRect.width - labelLocation - extraSpace;
            }
        };
        AccumulationDataLabel.prototype.getLabelLocation = function (point, position) {
            if (position === void 0) { position = 'Outside'; }
            if (this.accumulation.type !== 'Pie') {
                position = position === 'OutsideLeft' ? 'OutsideLeft' : point.labelPosition || position;
                var location_2 = {
                    x: point.symbolLocation.x,
                    y: point.symbolLocation.y - point.labelOffset.y
                };
                switch (position) {
                    case 'Inside':
                        location_2.y = point.region.y + point.region.height / 2;
                        break;
                    case 'Outside':
                        location_2.x += point.labelOffset.x;
                        break;
                    case 'OutsideLeft':
                        location_2.x -= point.labelOffset.x;
                }
                return location_2;
            }
            else {
                return helper_1.degreeToLocation(point.midAngle, (this.isVariousRadius() ? helper_1.stringToNumber(point.sliceRadius, this.accumulation.pieSeriesModule.seriesRadius) :
                    this.radius), this.center);
            }
        };
        AccumulationDataLabel.prototype.getConnectorStartPoint = function (point, connector) {
            var position;
            if (!this.isCircular() && point.region.x > point.labelRegion.x) {
                position = 'OutsideLeft';
            }
            return this.isCircular() ? helper_1.degreeToLocation(point.midAngle, (this.isVariousRadius() ? helper_1.stringToNumber(point.sliceRadius, this.accumulation.pieSeriesModule.seriesRadius) :
                this.radius) - connector.width, this.center) : this.getLabelLocation(point, position);
        };
        AccumulationDataLabel.prototype.findAreaRect = function () {
            this.areaRect = new ej2_svg_base_1.Rect(0, 0, this.accumulation.availableSize.width, this.accumulation.availableSize.height);
            var margin = this.accumulation.margin;
            helper_2.subtractThickness(this.areaRect, new helper_2.Thickness(margin.left, margin.right, margin.top, margin.bottom));
        };
        AccumulationDataLabel.prototype.renderDataLabel = function (point, dataLabel, parent, points, series, templateElement, redraw) {
            var id = this.accumulation.element.id + '_datalabel_Series_' + series + '_';
            var datalabelGroup = this.accumulation.renderer.createGroup({ id: id + 'g_' + point.index });
            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));
            point.label = this.getDatalabelText(dataLabel.format, this.accumulation, point.originalText || point.y.toString());
            var argsData = {
                cancel: false, name: constants_1.textRender, series: this.accumulation.visibleSeries[0], point: point,
                text: point.label, border: border, color: dataLabel.fill, template: this.accumulation.enableHtmlSanitizer ?
                    this.accumulation.sanitize(dataLabel.template) : dataLabel.template, font: argsFont
            };
            this.accumulation.trigger(constants_1.textRender, argsData);
            point.argsData = argsData;
            var isTemplate = argsData.template !== null;
            point.labelVisible = !argsData.cancel;
            point.text = point.label = argsData.text;
            point.labelCollection = [];
            this.marginValue = argsData.border.width ? (5 + argsData.border.width) : 1;
            var childElement = ej2_base_1.createElement('div', {
                id: this.accumulation.element.id + '_Series_' + 0 + '_DataLabel_' + point.index,
                styles: 'position: absolute;background-color:' + argsData.color + ';' +
                    helper_5.getFontStyle(dataLabel.font, this.accumulation.themeStyle.datalabelFont) + ';border:' + argsData.border.width + 'px solid ' + argsData.border.color + ';'
            });
            this.calculateLabelSize(isTemplate, childElement, point, points, argsData, datalabelGroup, id, dataLabel, redraw);
        };
        AccumulationDataLabel.prototype.getDatalabelText = function (labelFormat, chart, labelText) {
            if (Number(labelText)) {
                var customLabelFormat = labelFormat.match('{value}') !== null;
                var format = chart.intl.getNumberFormat({
                    format: customLabelFormat ? '' : labelFormat,
                    useGrouping: chart.useGroupingSeparator
                });
                labelText = customLabelFormat ? labelFormat.replace('{value}', format(parseFloat(labelText))) : format(parseFloat(labelText));
            }
            return labelText;
        };
        AccumulationDataLabel.prototype.calculateLabelSize = function (isTemplate, childElement, point, points, argsData, datalabelGroup, id, dataLabel, redraw, clientRect, isReactCallback) {
            this.calculateLabelCollection(point, dataLabel);
            var textSize = isTemplate ? (isReactCallback ? { width: clientRect.width, height: clientRect.height } :
                this.getTemplateSize(childElement, point, argsData, redraw, isTemplate, points, datalabelGroup, id, dataLabel)) : this.getTextSize(point.labelCollection, dataLabel);
            textSize.height += 4;
            textSize.width += 4;
            point.textSize = textSize;
            point.templateElement = childElement;
            this.getDataLabelPosition(point, dataLabel, textSize, points);
            Eif (point.labelRegion) {
                this.correctLabelRegion(point.labelRegion, point.textSize);
            }
        };
        AccumulationDataLabel.prototype.drawDataLabels = function (series, dataLabel, parent, templateElement, redraw) {
            var angle;
            var degree;
            var modifiedPoints = series.leftSidePoints.concat(series.rightSidePoints);
            modifiedPoints.sort(function (a, b) { return a.index - b.index; });
            if (series.type === 'Pie' && this.accumulation.enableSmartLabels) {
                this.extendedLabelsCalculation();
            }
            for (var _i = 0, modifiedPoints_1 = modifiedPoints; _i < modifiedPoints_1.length; _i++) {
                var point = modifiedPoints_1[_i];
                if (!ej2_base_1.isNullOrUndefined(point.argsData) && !ej2_base_1.isNullOrUndefined(point.y)) {
                    this.finalizeDatalabels(point, modifiedPoints, dataLabel);
                    var id = this.accumulation.element.id + '_datalabel_Series_' + 0 + '_';
                    var datalabelGroup = this.accumulation.renderer.createGroup({ id: id + 'g_' + point.index });
                    datalabelGroup.setAttribute('aria-hidden', 'true');
                    var dataLabelElement = void 0;
                    var location_3 = void 0;
                    var element = void 0;
                    if (point.visible && point.labelVisible) {
                        angle = degree = dataLabel.angle;
                        if (point.argsData.template) {
                            this.setTemplateStyle(point.templateElement, point, templateElement, dataLabel.font.color, point.color, redraw);
                        }
                        else {
                            location_3 = new helper_1.ChartLocation(point.labelRegion.x + this.marginValue, point.labelRegion.y
                                + (point.textSize.height * 3 / (point.labelCollection.length * 4)) + this.marginValue);
                            element = helper_2.getElement(id + 'shape_' + point.index);
                            var startLocation = element ? new helper_1.ChartLocation(+element.getAttribute('x'), +element.getAttribute('y')) : null;
                            var textWidth = point.textSize.width;
                            if (dataLabel.enableRotation) {
                                if (angle === 0) {
                                    if (point.labelPosition === 'Outside') {
                                        degree = 0;
                                    }
                                    else if (point.midAngle >= 90 && point.midAngle <= 260) {
                                        degree = point.midAngle + 180;
                                    }
                                    else {
                                        degree = point.midAngle;
                                    }
                                }
                                else {
                                    degree = (angle > 360) ? angle - 360 : (angle < -360) ? angle + 360 : angle;
                                }
                            }
                            else {
                                degree = 0;
                            }
                            var rotate = 'rotate(' + degree + ',' + (location_3.x + (textWidth / 2)) + ',' + (location_3.y) + ')';
                            point.transform = rotate;
                            dataLabelElement = this.accumulation.renderer.drawRectangle(new helper_3.RectOption(id + 'shape_' + point.index, point.argsData.color, point.argsData.border, 1, point.labelRegion, dataLabel.rx, dataLabel.ry, rotate, series.dataLabel.border.dashArray));
                            helper_1.appendChildElement(false, datalabelGroup, dataLabelElement, redraw, true, 'x', 'y', startLocation, null, false, false, null, this.accumulation.duration);
                            helper_3.textElement(this.accumulation.renderer, new ej2_svg_base_1.TextOption(id + 'text_' + point.index, location_3.x, location_3.y, this.accumulation.enableRtl ? 'end' : 'start', point.labelCollection, rotate, 'auto', degree), point.argsData.font, point.argsData.font.color || this.getSaturatedColor(point, point.argsData.color), datalabelGroup, false, redraw, true, false, this.accumulation.duration, null, null, null, null, true, this.accumulation.themeStyle.datalabelFont);
                            element = null;
                        }
                        if (this.accumulation.accumulationLegendModule && this.accumulation.legendSettings.visible && !this.accumulation.redraw && (dataLabel.position === 'Outside'
                            || this.accumulation.enableSmartLabels)) {
                            this.accumulation.visibleSeries[0].findMaxBounds(this.accumulation.visibleSeries[0].labelBound, point.labelRegion);
                        }
                        if (point.labelPosition === 'Outside') {
                            var element_1 = helper_2.getElement(id + 'connector_' + point.index);
                            var previousDirection = element_1 ? element_1.getAttribute('d') : '';
                            var pathElement = this.accumulation.renderer.drawPath(new ej2_svg_base_1.PathOption(id + 'connector_' + point.index, 'transparent', dataLabel.connectorStyle.width, dataLabel.connectorStyle.color || point.color, 1, dataLabel.connectorStyle.dashArray, this.getConnectorPath(ej2_base_1.extend({}, point.labelRegion, null, true), point, dataLabel, point.labelAngle)));
                            helper_1.appendChildElement(false, datalabelGroup, pathElement, redraw, true, null, null, null, previousDirection, false, false, null, this.accumulation.duration);
                        }
                        helper_1.appendChildElement(false, parent, datalabelGroup, redraw);
                    }
                    else if (helper_2.getElement(datalabelGroup.id)) {
                        (helper_2.getElement(datalabelGroup.id)).parentNode.removeChild(helper_2.getElement(datalabelGroup.id));
                    }
                }
            }
            if (this.accumulation.type === 'Pie' && dataLabel.textWrap === 'Normal' && dataLabel.textOverflow === 'Clip') {
                this.dataLabelClipPath(dataLabel, parent);
            }
        };
        AccumulationDataLabel.prototype.dataLabelClipPath = function (dataLabel, parent) {
            var id = this.accumulation.element.id + '_datalabel_Series_' + 0 + '_';
            var clippath = this.accumulation.renderer.createClipPath({ id: id + 'clipPath' });
            var clipRect;
            var radius = this.accumulation.pieSeriesModule.pieBaseRadius;
            if (dataLabel.position === 'Inside') {
                clipRect = this.accumulation.renderer.drawCircle(new helper_4.CircleOption(id + 'clipPath_rect', 'transparent', { width: 0 }, 0, this.center.x, this.center.y, radius));
            }
            else if (dataLabel.maxWidth) {
                var x = this.center.x - radius - helper_1.stringToNumber((dataLabel.connectorStyle.length || '4%'), radius) - dataLabel.maxWidth;
                var y = this.center.y - radius - helper_1.stringToNumber((dataLabel.connectorStyle.length || '4%'), radius) - dataLabel.maxWidth;
                var height = (radius + helper_1.stringToNumber((dataLabel.connectorStyle.length || '4%'), radius) + dataLabel.maxWidth) * 2;
                var width = height;
                Eif (this.accumulation.legendSettings.visible) {
                    var legendModule = this.accumulation.accumulationLegendModule;
                    if (legendModule.position === 'Left') {
                        width = (legendModule.legendBounds.x + legendModule.legendBounds.width - x) > 0 ?
                            (width - (legendModule.legendBounds.width - x)) : width;
                        x = (legendModule.legendBounds.x + legendModule.legendBounds.width) < x ? x :
                            (legendModule.legendBounds.x + legendModule.legendBounds.width);
                    }
                    else Eif (legendModule.position === 'Right') {
                        width = (x + width - legendModule.legendBounds.x) > 0 ? (width - (x + width - legendModule.legendBounds.x)) : width;
                    }
                }
                clipRect = this.accumulation.renderer.drawRectangle(new helper_3.RectOption(id + 'clipPath_rect', 'transparent', { width: 0 }, 0, new ej2_svg_base_1.Rect(x, y, height, width), 0, 0));
            }
            if (dataLabel.position === 'Inside' || dataLabel.maxWidth) {
                clippath.appendChild(clipRect);
                helper_1.appendChildElement(false, this.accumulation.svgObject, clippath);
                parent.style.cssText = 'clip-path:url(#' + clippath.id + ')';
            }
        };
        AccumulationDataLabel.prototype.finalizeDatalabels = function (point, points, dataLabel) {
            if (this.isOverlapping(point, points) ||
                (this.titleRect && point.labelRegion && helper_1.isOverlap(point.labelRegion, this.titleRect))) {
                if (this.isCircular() && point.labelPosition === 'Outside' && this.accumulation.enableSmartLabels) {
                    this.setPointVisibileFalse(point);
                }
            }
            if (this.accumulation.accumulationLegendModule && this.accumulation.legendSettings.visible &&
                point.labelVisible && point.labelRegion && (!dataLabel.maxWidth ? dataLabel.textOverflow === 'Clip' ? dataLabel.textWrap !== 'Normal' : true : false)) {
                var rect = this.accumulation.accumulationLegendModule.legendBounds;
                Iif (this.accumulation.visibleSeries[0].type !== 'Pie' && this.accumulation.legendSettings.position === 'Left'
                    && dataLabel.position === 'Outside') {
                    point.labelRegion.x = point.labelRegion.x + rect.width;
                }
                var padding = this.accumulation.legendSettings.border.width / 2;
                this.textTrimming(point, new ej2_svg_base_1.Rect(rect.x - padding, rect.y - padding, rect.width + (2 * padding), rect.height + (2 * padding)), dataLabel.font, this.accumulation.accumulationLegendModule.position, dataLabel);
            }
            if (point.labelVisible && point.labelRegion && (!dataLabel.maxWidth ? dataLabel.textOverflow === 'Clip' ? dataLabel.textWrap !== 'Normal' : true : false)) {
                var position = this.isCircular() ? (point.labelRegion.x >= this.center.x) ? 'InsideRight' : 'InsideLeft' :
                    (point.labelRegion.x >= point.region.x) ? 'InsideRight' : 'InsideLeft';
                this.textTrimming(point, this.areaRect, dataLabel.font, position, dataLabel);
            }
            if (point.labelVisible && point.labelRegion && !dataLabel.maxWidth && dataLabel.textOverflow !== 'Clip' && this.accumulation.enableSmartLabels && ((point.labelRegion.y + point.labelRegion.height / 2 >
                this.areaRect.y + this.areaRect.height || point.labelRegion.y < this.areaRect.y) || (point.labelRegion.x < this.areaRect.x ||
                point.labelRegion.x + point.labelRegion.width > this.areaRect.x + this.areaRect.width))) {
                this.setPointVisibileFalse(point);
            }
        };
        AccumulationDataLabel.prototype.getTemplateSize = function (element, point, argsData, redraw, isTemplate, points, datalabelGroup, id, dataLabel) {
            element = helper_5.createTemplate(element, point.index, argsData.template, this.accumulation, point, this.accumulation.visibleSeries[0], this.accumulation.element.id + '_DataLabel', 0, argsData, isTemplate, points, datalabelGroup, id, dataLabel, redraw);
            var clientRect = helper_5.measureElementRect(element, redraw);
            return { width: clientRect.width, height: clientRect.height };
        };
        AccumulationDataLabel.prototype.setTemplateStyle = function (childElement, point, parent, labelColor, fill, redraw) {
            childElement.style.left = (point.labelRegion.x) + 'px';
            childElement.style.top = (point.labelRegion.y) + 'px';
            childElement.style.color = labelColor || this.getSaturatedColor(point, point.labelPosition === 'Inside' ? fill : this.getLabelBackground(point));
            Iif (this.accumulation.isBlazor) {
                var position = this.isCircular() ? (point.labelRegion.x >= this.center.x) ? 'InsideRight' : 'InsideLeft' :
                    (point.labelRegion.x >= point.region.x) ? 'InsideRight' : 'InsideLeft';
                if (position === 'InsideRight') {
                    childElement.style.transform = 'translate(0%, -50%)';
                }
                else {
                    childElement.style.transform = 'translate(-100%, -50%)';
                }
            }
            if (childElement.childElementCount) {
                helper_1.appendChildElement(false, parent, childElement, redraw, true, 'left', 'top');
                this.doTemplateAnimation(this.accumulation, childElement);
            }
        };
        AccumulationDataLabel.prototype.getSaturatedColor = function (point, color) {
            var saturatedColor;
            Eif (this.marginValue >= 1) {
                saturatedColor = color === 'transparent' ? this.getLabelBackground(point) : color;
            }
            else {
                saturatedColor = this.getLabelBackground(point);
            }
            saturatedColor = (saturatedColor === 'transparent') ? ((this.accumulation.theme.indexOf('Dark') > -1 || this.accumulation.theme.indexOf('HighContrast') > -1) ? 'black' : 'white') : saturatedColor;
            var rgbValue = helper_4.convertHexToColor(helper_4.colorNameToHex(saturatedColor));
            var contrast = Math.round((rgbValue.r * 299 + rgbValue.g * 587 + rgbValue.b * 114) / 1000);
            return this.accumulation.theme === 'Bootstrap5' ? '#212529' : this.accumulation.theme === 'Bootstrap5Dark' ? '#DEE2E6' : contrast >= 128 ? 'black' : 'white';
        };
        AccumulationDataLabel.prototype.doTemplateAnimation = function (accumulation, element) {
            var series = accumulation.visibleSeries[0];
            var delay = series.animation.delay + series.animation.duration;
            if (((series.animation.enable && ej2_base_1.animationMode !== 'Disable') || ej2_base_1.animationMode === 'Enable') && accumulation.animateSeries) {
                element.style.visibility = 'hidden';
                helper_5.templateAnimate(element, delay, 200, 'ZoomIn');
            }
        };
        AccumulationDataLabel.prototype.getLabelBackground = function (point) {
            return point.labelPosition === 'Outside' ?
                this.accumulation.background || this.accumulation.themeStyle.background : !point.y ? this.accumulation.theme.indexOf('dark') ? 'white' : 'black' : point.color;
        };
        AccumulationDataLabel.prototype.correctLabelRegion = function (labelRegion, textSize, padding) {
            Eif (padding === void 0) { padding = 4; }
            labelRegion.height -= padding;
            labelRegion.width -= padding;
            labelRegion.x += padding / 2;
            labelRegion.y += padding / 2;
            textSize.height -= padding;
            textSize.width -= padding;
        };
        AccumulationDataLabel.prototype.getModuleName = function () {
            return 'AccumulationDataLabel';
        };
        AccumulationDataLabel.prototype.destroy = function () {
        };
        AccumulationDataLabel.prototype.extendedLabelsCalculation = function () {
            var _this = this;
            var series = this.accumulation.series[0];
            series.rightSidePoints.forEach(function (point, index, halfSidePoints) {
                point.initialLabelRegion = point.labelRegion;
                point.isLabelUpdated = 0;
                _this.skipPoints(point, halfSidePoints, index);
            });
            series.leftSidePoints.forEach(function (point, index, halfSidePoints) {
                point.initialLabelRegion = point.labelRegion;
                point.isLabelUpdated = 0;
                _this.skipPoints(point, halfSidePoints, index);
            });
            this.arrangeLeftSidePoints(series);
            this.isIncreaseAngle = false;
            this.arrangeRightSidePoints(series);
        };
        AccumulationDataLabel.prototype.arrangeRightSidePoints = function (series) {
            var startFresh;
            var angleChanged;
            var rightSideRenderPoints = series.rightSidePoints.filter(function (point) { return (point.labelVisible && point.labelPosition === 'Outside'); });
            this.rightSideRenderingPoints = rightSideRenderPoints;
            var checkAngle;
            var currentPoint;
            var lastPoint = rightSideRenderPoints[rightSideRenderPoints.length - 1];
            var nextPoint;
            if (lastPoint) {
                Iif (lastPoint.labelAngle > 90 && lastPoint.labelAngle < 270) {
                    this.isIncreaseAngle = true;
                    this.changeLabelAngle(lastPoint, 89);
                }
            }
            for (var i = rightSideRenderPoints.length - 1; i >= 0; i--) {
                currentPoint = rightSideRenderPoints[i];
                nextPoint = rightSideRenderPoints[i + 1];
                if (this.isOverlapWithNext(currentPoint, rightSideRenderPoints, i) && currentPoint.labelVisible
                    || !(currentPoint.labelAngle <= 90 || currentPoint.labelAngle >= 270)) {
                    checkAngle = lastPoint.labelAngle + 10;
                    angleChanged = true;
                    if (startFresh) {
                        this.isIncreaseAngle = false;
                    }
                    else if (checkAngle > 90 && checkAngle < 270 && nextPoint.isLabelUpdated) {
                        this.isIncreaseAngle = true;
                    }
                    if (!this.isIncreaseAngle) {
                        for (var k = i + 1; k < rightSideRenderPoints.length; k++) {
                            this.increaseAngle(rightSideRenderPoints[k - 1], rightSideRenderPoints[k], series, true);
                        }
                    }
                    else {
                        for (var k = i + 1; k > 0; k--) {
                            this.decreaseAngle(rightSideRenderPoints[k], rightSideRenderPoints[k - 1], series, true);
                        }
                    }
                }
                else {
                    if (angleChanged && nextPoint && !nextPoint.isLabelUpdated) {
                        startFresh = true;
                    }
                }
            }
        };
        AccumulationDataLabel.prototype.arrangeLeftSidePoints = function (series) {
            var _this = this;
            var leftSideRenderPoints = series.leftSidePoints.filter(function (point) { return (point.labelVisible && point.labelPosition === 'Outside'); });
            this.leftSideRenderingPoints = leftSideRenderPoints;
            var previousPoint;
            var currentPoint;
            var angleChanged;
            var startFresh;
            for (var i = 0; i < leftSideRenderPoints.length; i++) {
                currentPoint = leftSideRenderPoints[i];
                previousPoint = leftSideRenderPoints[i - 1];
                if (this.isOverlapWithPrevious(currentPoint, leftSideRenderPoints, i) && currentPoint.labelVisible
                    || !(currentPoint.labelAngle < 270)) {
                    angleChanged = true;
                    Iif (startFresh) {
                        this.isIncreaseAngle = false;
                    }
                    Eif (!this.isIncreaseAngle) {
                        for (var k = i; k > 0; k--) {
                            this.decreaseAngle(leftSideRenderPoints[k], leftSideRenderPoints[k - 1], series, false);
                            leftSideRenderPoints.filter(function (point, index) {
                                if (point.isLabelUpdated && leftSideRenderPoints[index].labelAngle - 10 < 100) {
                                    _this.isIncreaseAngle = true;
                                }
                            });
                        }
                    }
                    else {
                        for (var k = i; k < leftSideRenderPoints.length; k++) {
                            this.increaseAngle(leftSideRenderPoints[k - 1], leftSideRenderPoints[k], series, false);
                        }
                    }
                }
                else {
                    Iif (angleChanged && previousPoint && previousPoint.isLabelUpdated) {
                        startFresh = true;
                    }
                }
            }
        };
        AccumulationDataLabel.prototype.decreaseAngle = function (currentPoint, previousPoint, series, isRightSide) {
            Iif (ej2_base_1.isNullOrUndefined(currentPoint) || ej2_base_1.isNullOrUndefined(previousPoint)) {
                return null;
            }
            var count = 1;
            if (isRightSide) {
                while (helper_1.isOverlap(currentPoint.labelRegion, previousPoint.labelRegion) || (!this.isVariousRadius() &&
                    !((previousPoint.labelRegion.height + previousPoint.labelRegion.y) < currentPoint.labelRegion.y))) {
                    var newAngle = previousPoint.midAngle - count;
                    if (newAngle < 0) {
                        newAngle = 360 + newAngle;
                    }
                    if (newAngle <= 270 && newAngle >= 90) {
                        newAngle = 270;
                        this.isIncreaseAngle = true;
                        break;
                    }
                    this.changeLabelAngle(previousPoint, newAngle);
                    count++;
                }
            }
            else {
                if (currentPoint.labelAngle > 270) {
                    this.changeLabelAngle(currentPoint, 270);
                    previousPoint.labelAngle = 270;
                }
                while (helper_1.isOverlap(currentPoint.labelRegion, previousPoint.labelRegion) || (!this.isVariousRadius() &&
                    ((currentPoint.labelRegion.y + currentPoint.labelRegion.height) > previousPoint.labelRegion.y))) {
                    var newAngle = previousPoint.midAngle - count;
                    if (!(newAngle <= 270 && newAngle >= 90)) {
                        newAngle = 90;
                        this.isIncreaseAngle = true;
                        break;
                    }
                    this.changeLabelAngle(previousPoint, newAngle);
                    Iif (helper_1.isOverlap(currentPoint.labelRegion, previousPoint.labelRegion) &&
                        !series.leftSidePoints.indexOf(previousPoint) && (newAngle - 1 < 90 && newAngle - 1 > 270)) {
                        this.changeLabelAngle(currentPoint, currentPoint.labelAngle + 1);
                        this.arrangeLeftSidePoints(series);
                        break;
                    }
                    count++;
                }
            }
        };
        AccumulationDataLabel.prototype.increaseAngle = function (currentPoint, nextPoint, series, isRightSide) {
            Iif (ej2_base_1.isNullOrUndefined(currentPoint) || ej2_base_1.isNullOrUndefined(nextPoint)) {
                return null;
            }
            var count = 1;
            Eif (isRightSide) {
                while (helper_1.isOverlap(currentPoint.labelRegion, nextPoint.labelRegion) || (!this.isVariousRadius() &&
                    !((currentPoint.labelRegion.y + currentPoint.labelRegion.height) < nextPoint.labelRegion.y))) {
                    var newAngle = nextPoint.midAngle + count;
                    Iif (newAngle < 270 && newAngle > 90) {
                        newAngle = 90;
                        this.isIncreaseAngle = true;
                        break;
                    }
                    this.changeLabelAngle(nextPoint, newAngle);
                    if (helper_1.isOverlap(currentPoint.labelRegion, nextPoint.labelRegion) && (newAngle + 1 > 90 && newAngle + 1 < 270) &&
                        this.rightSideRenderingPoints.indexOf(nextPoint) === this.rightSideRenderingPoints.length - 1) {
                        this.changeLabelAngle(currentPoint, currentPoint.labelAngle - 1);
                        nextPoint.labelRegion = nextPoint.initialLabelRegion;
                        this.arrangeRightSidePoints(series);
                        break;
                    }
                    Iif (count > 360) {
                        break;
                    }
                    count++;
                }
            }
            else {
                while (helper_1.isOverlap(currentPoint.labelRegion, nextPoint.labelRegion) || (!this.isVariousRadius() &&
                    (currentPoint.labelRegion.y < (nextPoint.labelRegion.y + nextPoint.labelRegion.height)))) {
                    var newAngle = nextPoint.midAngle + count;
                    if (!(newAngle < 270 && newAngle > 90)) {
                        newAngle = 270;
                        this.isIncreaseAngle = false;
                        break;
                    }
                    this.changeLabelAngle(nextPoint, newAngle);
                    if (count > 360) {
                        break;
                    }
                    count++;
                }
            }
        };
        AccumulationDataLabel.prototype.changeLabelAngle = function (currentPoint, newAngle) {
            var dataLabel = this.accumulation.series[0].dataLabel;
            var variableR;
            Iif (this.isVariousRadius()) {
                variableR = this.accumulation.pieSeriesModule.getLabelRadius(this.accumulation.visibleSeries[0], currentPoint);
            }
            var labelRadius = (currentPoint.labelPosition === 'Outside' && this.accumulation.enableSmartLabels &&
                dataLabel.position === 'Inside') ?
                this.radius + helper_1.stringToNumber(dataLabel.connectorStyle.length || '4%', this.accumulation.pieSeriesModule.size / 2) :
                (!this.isVariousRadius() ? this.accumulation.pieSeriesModule.labelRadius + 10 : variableR);
            var radius = (!this.isVariousRadius() ? labelRadius : variableR);
            this.getLabelRegion(currentPoint, 'Outside', currentPoint.textSize, radius, this.marginValue, newAngle);
            currentPoint.isLabelUpdated = 1;
            currentPoint.labelAngle = newAngle;
        };
        AccumulationDataLabel.prototype.isOverlapWithPrevious = function (currentPoint, points, currentPointIndex) {
            for (var i = 0; i < currentPointIndex; i++) {
                if (i !== points.indexOf(currentPoint) &&
                    points[i].visible && points[i].labelVisible &&
                    points[i].labelRegion && currentPoint.labelRegion &&
                    currentPoint.labelVisible && helper_1.isOverlap(currentPoint.labelRegion, points[i].labelRegion)) {
                    return true;
                }
            }
            return false;
        };
        AccumulationDataLabel.prototype.isOverlapWithNext = function (point, points, pointIndex) {
            for (var i = pointIndex; i < points.length; i++) {
                if (i !== points.indexOf(point) && points[i].visible &&
                    points[i].labelVisible && points[i].labelRegion &&
                    point.labelRegion && point.labelVisible && helper_1.isOverlap(point.labelRegion, points[i].labelRegion)) {
                    return true;
                }
            }
            return false;
        };
        AccumulationDataLabel.prototype.skipPoints = function (currentPoint, halfsidePoints, pointIndex) {
            if (pointIndex > 0 && ((currentPoint.midAngle < 285 && currentPoint.midAngle > 255) ||
                (currentPoint.midAngle < 105 && currentPoint.midAngle > 75))) {
                var previousPoint = halfsidePoints[pointIndex - 1];
                var angleDiff = currentPoint.endAngle % 360 - currentPoint.startAngle % 360;
                var prevAngleDiff = previousPoint.endAngle % 360 - previousPoint.startAngle % 360;
                if (prevAngleDiff <= angleDiff && angleDiff < 5 && previousPoint.labelVisible) {
                    this.setPointVisibleTrue(currentPoint);
                }
            }
            else if (pointIndex > 1 && ((currentPoint.midAngle < 300 && currentPoint.midAngle > 240) ||
                (currentPoint.midAngle < 120 && currentPoint.midAngle > 60))) {
                var prevPoint = halfsidePoints[pointIndex - 1];
                var secondPrevPoint = halfsidePoints[pointIndex - 2];
                var angleDiff = currentPoint.endAngle % 360 - currentPoint.startAngle % 360;
                var prevAngleDiff = prevPoint.endAngle % 360 - prevPoint.startAngle % 360;
                var thirdAngleDiff = secondPrevPoint.endAngle % 360 - secondPrevPoint.startAngle % 360;
                if (angleDiff < 3 && prevAngleDiff < 3 && thirdAngleDiff < 3 && prevPoint.labelVisible && currentPoint.labelVisible) {
                    this.setPointVisibleTrue(currentPoint);
                }
            }
        };
        AccumulationDataLabel.prototype.getPerpendicularDistance = function (startPoint, point) {
            var increasedLocation;
            var add = 10;
            var height = add + 10 * Math.sin(point.midAngle * Math.PI / 360);
            if (point.midAngle > 270 && point.midAngle < 360) {
                increasedLocation = new helper_1.ChartLocation(startPoint.x + height * (Math.cos((360 - point.midAngle) * Math.PI / 180)), startPoint.y - height * (Math.sin((360 - point.midAngle) * Math.PI / 180)));
            }
            else if (point.midAngle > 0 && point.midAngle < 90) {
                increasedLocation = new helper_1.ChartLocation(startPoint.x + height * (Math.cos((point.midAngle) * Math.PI / 180)), startPoint.y + height * (Math.sin((point.midAngle) * Math.PI / 180)));
            }
            else Iif (point.midAngle > 0 && point.midAngle < 90) {
                increasedLocation = new helper_1.ChartLocation(startPoint.x - height * (Math.cos((point.midAngle - 90) * Math.PI / 180)), startPoint.y + height * (Math.sin((point.midAngle - 90) * Math.PI / 180)));
            }
            else {
                increasedLocation = new helper_1.ChartLocation(startPoint.x - height * (Math.cos((point.midAngle - 180) * Math.PI / 180)), startPoint.y - height * (Math.sin((point.midAngle - 180) * Math.PI / 180)));
            }
            return increasedLocation;
        };
        return AccumulationDataLabel;
    }(accumulation_base_1.AccumulationBase));
    exports.AccumulationDataLabel = AccumulationDataLabel;
});