all files / heatmap/axis/ axis-helpers.js

98.58% Statements 694/704
86.86% Branches 714/822
100% Functions 33/33
98.58% Lines 694/704
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   267× 267× 267×   330× 330× 330× 330× 330× 281×   330× 330× 660× 660× 330× 281×   330× 330× 330×     330× 330× 330× 330×   660× 49×   660× 562×     330× 281×     330× 330× 330×   330× 330× 330×   330× 330×   330× 179× 179× 179× 179× 179×   179× 179× 179×     330× 231× 231× 231× 231×   231× 231× 231× 231×   231× 231× 231× 190×     41×       305× 305× 305× 305× 305× 305× 610× 610× 23× 23×   587× 58× 58×   529× 528× 528×   610×     355× 355× 355× 355× 710× 710× 710× 710× 710× 710× 582× 300×     282× 282×       128× 55× 55×     73×         355× 355× 355× 710× 710× 710× 32× 14× 14×   32×   710× 300× 300×   710× 73× 73×   710× 710× 90× 90×       330× 330× 330× 330× 330× 330× 330× 330× 330× 330× 327×         330×   330× 330× 330× 330× 330× 330× 330× 330× 330× 281× 281×   330×   330× 330× 1630× 1630×     1630× 1630× 1630× 1630× 1630× 108× 108×     1522× 24× 24× 24× 24×   1522×   1630× 1630× 1630× 1630× 1630×   1630×     1630× 22×     1630× 1513×   117× 30× 30×   1630× 132×   1630× 15×   15×         12×         1615×   1630× 1630× 1630× 238× 238× 238× 238×   238×   238×   1630× 49×   1630× 49×   1630× 49×   1630× 22×   1630×   1630×   1630× 1630× 1630×       1630× 132×     1498×     1630× 1622×   1622×         1630× 72× 72× 72× 72×   1630×     330× 281× 281×     102× 102× 113× 113×   102×   2480× 2480× 2480× 2480× 2506× 2506× 2501× 2501×     2480×   222× 222× 102×     120×   222×   330× 330× 330× 330× 330× 330× 330× 330× 328× 20× 20×         330×   330× 330× 330× 330× 330× 330× 330× 330× 281× 281×   330× 330× 2372× 2372× 2372× 2372×   2372× 2372× 2372× 2372× 2372× 2372× 84× 84× 96×       84× 60× 60× 68×     84×     2288×   2288×   2372× 2372× 12×     2360× 12×   2372× 2372× 72× 72× 72× 72× 72× 72×       2372× 2372×     2372× 2372×       2372× 90×     2282×     2372× 2259×   2259×       113× 113×   2372× 2372× 2372× 29× 29× 29× 29×     330× 281× 281×     1630× 1630× 1630× 1630× 1630×   1630× 1630× 1630× 1630× 1630× 1630× 1630× 1630× 1630× 1630×   1446×   1446×           157×   157×           1630× 184×     2372× 2372× 2372× 2372× 2372× 2372×   2372× 2372× 2372× 2372× 2372× 2372× 2372×   2213×   2213×           153×   153×           2372× 159×     343× 343× 343× 343× 334× 334×         49× 49× 48×   49× 31×     18×   49× 48×     31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 31× 61× 61× 98× 95×     95×   95×     95×   95×   95×     95×     95× 95× 95× 95× 95× 95× 95× 95× 95× 95× 95× 39× 39×   56× 14× 14×     42×   95×   95× 95× 95× 37× 37×   58× 56× 56×   95×         87×   95× 94×   95× 36×   95× 95×       61× 61× 61×     31× 30×     95× 95× 95×   95× 95×   68×   68×               14× 14× 14×       14×   95×   18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 28× 28× 28× 42×     42× 14×   42×     42×   42×   42× 42× 42× 42× 42× 42× 42× 42×   42× 42× 42× 42× 32×     10×     42× 29×   13×     10×   42× 42×   42× 42× 42× 42× 42×   42× 42×     28× 28× 28×     18× 18×     42× 42× 42× 42×   42×   22×   22×               16× 16× 16× 16×       16×   42×   89× 89× 89× 89× 89× 88×         277× 277× 277× 220×   220× 220× 220× 220×     57× 57× 57×   277×   277× 277× 277× 220×   220× 220× 220× 220×     57× 57× 57× 57×   277×   114× 114× 114× 114× 114× 114× 114× 114× 114× 114× 1444× 1444× 1444× 104× 104×   100×   94×     92×     92×     1444× 14×             114×   263× 263× 263× 263× 263×        
define(["require", "exports", "../utils/helper", "../utils/helper", "@syncfusion/ej2-base"], function (require, exports, helper_1, helper_2, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AxisHelper = (function () {
        function AxisHelper(heatMap) {
            this.heatMap = heatMap;
            this.padding = 10;
            this.drawSvgCanvas = new helper_2.DrawSvgCanvas(heatMap);
        }
        AxisHelper.prototype.renderAxes = function () {
            this.initialClipRect = this.heatMap.initialClipRect;
            var heatMap = this.heatMap;
            var axisElement;
            var element;
            if (!heatMap.enableCanvasRendering) {
                axisElement = this.heatMap.renderer.createGroup({ id: heatMap.element.id + 'AxisCollection' });
            }
            var axes = this.heatMap.axisCollections;
            for (var i = 0, len = axes.length; i < len; i++) {
                var axis = axes[i];
                if (axis.orientation === 'Horizontal') {
                    if (!heatMap.enableCanvasRendering) {
                        element = this.heatMap.renderer.createGroup({ id: heatMap.element.id + 'XAxisGroup' });
                    }
                    this.drawXAxisLine(element, axis);
                    this.drawXAxisTitle(axis, element, axis.rect);
                    this.drawXAxisLabels(axis, element, axis.rect);
                }
                else {
                    element = heatMap.renderer.createGroup({ id: heatMap.element.id + 'YAxisGroup' });
                    this.drawYAxisLine(element, axis);
                    this.drawYAxisTitle(axis, element, axis.rect);
                    this.drawYAxisLabels(axis, element, axis.rect);
                }
                if (axis.multiLevelLabels.length > 0) {
                    this.drawMultiLevels(element, axis);
                }
                if (!heatMap.enableCanvasRendering) {
                    axisElement.appendChild(element);
                }
            }
            if (!heatMap.enableCanvasRendering) {
                this.heatMap.svgObject.appendChild(axisElement);
            }
        };
        AxisHelper.prototype.drawXAxisLine = function (parent, axis) {
            var y = this.initialClipRect.y + (!axis.opposedPosition ? this.initialClipRect.height : 0);
            var line = new helper_2.LineOption(this.heatMap.element.id + '_XAxisLine', new helper_2.Line(this.initialClipRect.x, y, this.initialClipRect.x + this.initialClipRect.width, y), 'transparent', 0);
            this.drawSvgCanvas.drawLine(line, parent);
        };
        AxisHelper.prototype.drawYAxisLine = function (parent, axis) {
            var x = this.initialClipRect.x + ((!axis.opposedPosition) ? 0 : this.initialClipRect.width);
            var line = new helper_2.LineOption(this.heatMap.element.id + '_YAxisLine', new helper_2.Line(x, this.initialClipRect.y, x, this.initialClipRect.height + this.initialClipRect.y), 'transparent', 0);
            this.drawSvgCanvas.drawLine(line, parent);
        };
        AxisHelper.prototype.drawXAxisTitle = function (axis, parent, rect) {
            var titlepadding = (axis.textStyle.size === '0px' ? 0 : 10);
            var y = rect.y + (!axis.opposedPosition ? (axis.maxLabelSize.height + titlepadding +
                helper_2.sum(axis.xAxisMultiLabelHeight)) : -(axis.maxLabelSize.height + titlepadding + helper_2.sum(axis.xAxisMultiLabelHeight)));
            if (axis.title.text) {
                var heatMap = this.heatMap;
                var title = axis.title;
                var elementSize = helper_1.measureText(title.text, title.textStyle);
                var padding = this.padding;
                var anchor = title.textStyle.textAlignment === 'Near' ? 'start' :
                    title.textStyle.textAlignment === 'Far' ? 'end' : 'middle';
                padding = axis.opposedPosition ? -(padding + elementSize.height / 4) : (padding + (3 * elementSize.height / 4));
                var options = new helper_1.TextOption(heatMap.element.id + '_XAxisTitle', new helper_2.TextBasic(rect.x + helper_2.titlePositionX(rect.width, 0, 0, title.textStyle), y + padding, anchor, title.text), title.textStyle, title.textStyle.color || heatMap.themeStyle.axisTitle);
                this.drawSvgCanvas.createText(options, parent, title.text);
            }
        };
        AxisHelper.prototype.drawYAxisTitle = function (axis, parent, rect) {
            if (axis.title.text) {
                var title = axis.title;
                var heatMap = this.heatMap;
                var labelRotation = (axis.opposedPosition) ? 90 : -90;
                var anchor = title.textStyle.textAlignment === 'Near' ? 'start' :
                    title.textStyle.textAlignment === 'Far' ? 'end' : 'middle';
                var padding = 10;
                padding = axis.opposedPosition ? padding : -padding;
                var titlepadding = (axis.textStyle.size === '0px' ? 0 : padding);
                var x = rect.x + titlepadding + ((axis.opposedPosition) ? axis.maxLabelSize.width + helper_2.sum(axis.yAxisMultiLabelHeight) :
                    -(axis.maxLabelSize.width + helper_2.sum(axis.yAxisMultiLabelHeight)));
                var y = rect.y + helper_2.titlePositionY(rect, 0, 0, title.textStyle) + (axis.opposedPosition ? this.padding : -this.padding);
                var options = new helper_1.TextOption(heatMap.element.id + '_YAxisTitle', new helper_2.TextBasic(x, y - this.padding, anchor, title.text, labelRotation, 'rotate(' + labelRotation + ',' + (x) + ',' + (y) + ')', 'auto'), title.textStyle, title.textStyle.color || heatMap.themeStyle.axisTitle);
                if (!this.heatMap.enableCanvasRendering) {
                    this.drawSvgCanvas.createText(options, parent, title.text);
                }
                else {
                    this.drawSvgCanvas.canvasDrawText(options, title.text, x, y);
                }
            }
        };
        AxisHelper.prototype.calculateVisibleLabels = function () {
            var heatmap = this.heatMap;
            var axis;
            var axisCollection = heatmap.axisCollections;
            var data = this.heatMap.dataSourceSettings;
            var processLabels = !(data && data.isJsonData && data.adaptorType === 'Cell');
            for (var i = 0, len = axisCollection.length; i < len; i++) {
                axis = axisCollection[i];
                if (axis.valueType === 'Numeric' && processLabels) {
                    axis.clearAxisLabel();
                    axis.calculateNumericAxisLabels(this.heatMap);
                }
                else if (axis.valueType === 'DateTime' && processLabels) {
                    axis.clearAxisLabel();
                    axis.calculateDateTimeAxisLabel(this.heatMap);
                }
                else if (axis.valueType === 'Category') {
                    axis.clearAxisLabel();
                    axis.calculateCategoryAxisLabels();
                }
                axis.tooltipLabels = axis.isInversed ? axis.tooltipLabels.reverse() : axis.tooltipLabels;
            }
        };
        AxisHelper.prototype.measureAxis = function (rect) {
            var heatmap = this.heatMap;
            var axis;
            var axisCollection = heatmap.axisCollections;
            for (var i = axisCollection.length - 1; i >= 0; i--) {
                axis = axisCollection[i];
                var padding = axis.textStyle.size === '0px' ? 0 : this.padding;
                axis.nearSizes = [];
                axis.farSizes = [];
                axis.computeSize(axis, heatmap, rect);
                if (!axis.opposedPosition) {
                    if (axis.orientation === 'Horizontal') {
                        rect.height -= (helper_2.sum(axis.nearSizes) + padding);
                    }
                    else {
                        rect.x += helper_2.sum(axis.nearSizes) + padding;
                        rect.width -= helper_2.sum(axis.nearSizes) + padding;
                    }
                }
                else {
                    if (axis.orientation === 'Horizontal') {
                        rect.y += helper_2.sum(axis.farSizes) + padding;
                        rect.height -= helper_2.sum(axis.farSizes) + padding;
                    }
                    else {
                        rect.width -= helper_2.sum(axis.farSizes) + padding;
                    }
                }
            }
        };
        AxisHelper.prototype.calculateAxisSize = function (rect) {
            var heatmap = this.heatMap;
            var axisCollection = heatmap.axisCollections;
            for (var i = 0, len = axisCollection.length; i < len; i++) {
                var axis = axisCollection[i];
                axis.rect = ej2_base_1.extend({}, rect, null, true);
                if (axis.orientation === 'Horizontal' && axis.multiLevelLabels.length !== 0) {
                    if (axis.opposedPosition) {
                        axis.rect.y += (axis.angle === 0 || axis.angle === 180 || axis.angle === 360 ? 0 : this.padding);
                        this.heatMap.initialClipRect.y += (axis.angle === 0 || axis.angle === 180 || axis.angle === 360 ? 0 : this.padding);
                    }
                    rect.height -= (axis.angle === 0 || axis.angle === 180 || axis.angle === 360 ? 0 : this.padding);
                }
                if (axis.orientation === 'Horizontal' && !axis.opposedPosition) {
                    axis.rect.y = rect.y + rect.height;
                    axis.rect.height = 0;
                }
                if (axis.orientation === 'Vertical' && axis.opposedPosition) {
                    axis.rect.x = rect.x + rect.width;
                    axis.rect.width = 0;
                }
                axis.multiLevelPosition = [];
                for (var i_1 = 0; i_1 < axis.multiLevelLabels.length; i_1++) {
                    var multiPosition = axis.multiPosition(axis, i_1);
                    axis.multiLevelPosition.push(multiPosition);
                }
            }
        };
        AxisHelper.prototype.drawXAxisLabels = function (axis, parent, rect) {
            var heatMap = this.heatMap;
            var labels = axis.axisLabels;
            var isLineBreak = false;
            var borderWidth = this.heatMap.cellSettings.border.width > 5 ? (this.heatMap.cellSettings.border.width / 2) : 0;
            var interval = (rect.width - borderWidth) / axis.axisLabelSize;
            var compactInterval = 0;
            var axisInterval = axis.interval ? axis.interval : 1;
            var tempintervel = rect.width / (axis.axisLabelSize / axis.axisLabelInterval);
            var temp = axis.axisLabelInterval;
            if (tempintervel > 0) {
                while (tempintervel < parseInt(axis.textStyle.size, 10)) {
                    temp = temp + 1;
                    tempintervel = rect.width / (axis.axisLabelSize / temp);
                }
            }
            else {
                temp = axis.tooltipLabels.length;
            }
            if (axis.axisLabelInterval < temp) {
                compactInterval = temp;
                labels = axis.tooltipLabels;
                axisInterval = temp;
            }
            var y;
            var padding = 10;
            var lableStrtX = rect.x + (!axis.isInversed ? 0 : rect.width);
            var labelPadding;
            var angle = axis.angle;
            padding = this.padding;
            var labelElement;
            var borderElement;
            if (!heatMap.enableCanvasRendering) {
                labelElement = this.heatMap.renderer.createGroup({ id: heatMap.element.id + 'XAxisLabels' });
                borderElement = this.heatMap.renderer.createGroup({ id: heatMap.element.id + 'XAxisLabelBorder' });
            }
            if (axis.isInversed && axis.labelIntersectAction === 'MultipleRows') {
                axis.multipleRow.reverse();
            }
            isLineBreak = helper_1.getIsLineBreakLabel(labels);
            for (var i = 0, len = labels.length; i < len; i++) {
                var lableRect = new helper_1.Rect(lableStrtX, rect.y, interval, rect.height);
                var label = (axis.textStyle.textOverflow !== 'Wrap' && !(isLineBreak) && axis.textStyle.textOverflow !== 'Trim' && axis.labelIntersectAction === 'Trim' && axis.isIntersect) ? axis.valueType !== 'DateTime' ||
                    axis.showLabelOn === 'None' ? helper_1.textTrim(interval * axisInterval, labels[i], axis.textStyle) :
                    helper_1.textTrim(axis.dateTimeAxisLabelInterval[i] * interval, labels[i], axis.textStyle) : labels[i];
                label = ((axis.enableTrim || axis.textStyle.textOverflow === 'Trim') && !isLineBreak) ? helper_1.textTrim((axis.textStyle.textOverflow === 'Trim' ? interval - (axis.border.width / 2) : axis.maxLabelLength), labels[i], axis.textStyle) : label;
                var wrappedLabel = label;
                var wrappedlabels = [];
                var rotateSize = new helper_1.Size(0, 0);
                if ((axis.textStyle.textOverflow === 'Wrap' || isLineBreak) && !axis.enableTrim) {
                    wrappedlabels = this.getLabels(wrappedLabel, interval - (axis.border.width / 2), axis, isLineBreak);
                    wrappedLabel = this.getMaxLabel(wrappedlabels, axis);
                }
                else {
                    if (isLineBreak && axis.enableTrim) {
                        wrappedlabels = this.getLabels(wrappedLabel, interval - (axis.border.width / 2), axis, isLineBreak);
                        wrappedLabel = helper_1.textTrim(axis.maxLabelLength, wrappedlabels[0], axis.textStyle);
                        wrappedLabel = (label.indexOf('<br>') !== -1 || label.indexOf('<br/>') !== -1) && wrappedLabel.indexOf('...') === -1 ? wrappedLabel + '...' : wrappedLabel;
                        wrappedlabels = [];
                    }
                    wrappedlabels.push(wrappedLabel);
                }
                var elementSize = helper_1.measureText(wrappedLabel, axis.textStyle);
                var transform = void 0;
                labelPadding = (axis.opposedPosition) ? -(padding) : (padding + ((angle % 360) === 0 ? (elementSize.height / 2) : 0));
                elementSize.width = axis.isInversed ? (elementSize.width > interval ? interval : elementSize.width) : elementSize.width;
                var x = lableRect.x + ((!axis.isInversed) ?
                    (lableRect.width / 2) - (elementSize.width / 2) : -((lableRect.width / 2) + (elementSize.width / 2)));
                Iif (axis.textStyle.textAlignment === 'Near') {
                    x = lableRect.x - ((!axis.isInversed) ? 0 : lableRect.width);
                }
                else if (axis.textStyle.textAlignment === 'Far') {
                    x = lableRect.x + ((!axis.isInversed) ?
                        (lableRect.width - elementSize.width) : -(elementSize.width));
                }
                if (axis.labelIntersectAction === 'Trim') {
                    x = (!axis.isInversed) ? (x >= lableRect.x ? x : lableRect.x) : (x > (lableStrtX - interval) ? x : (lableStrtX - interval));
                }
                else if (angle % 180 === 0) {
                    x = x < rect.x ? rect.x : x;
                    x = ((x + elementSize.width) > (rect.x + rect.width)) ? (rect.x + rect.width - elementSize.width) : x;
                }
                if ((axis.textStyle.textOverflow === 'Wrap' || isLineBreak) && !axis.isInversed) {
                    x = x < lableRect.x ? lableRect.x : x;
                }
                if (axis.labelIntersectAction === 'MultipleRows' && axis.textStyle.textOverflow !== 'Wrap' && axis.textStyle.textOverflow !== 'Trim' && axis.labelRotation === 0) {
                    var a = axis.opposedPosition ? -(axis.multipleRow[i].index - 1) :
                        (axis.multipleRow[i].index - 1);
                    if (axis.multipleRow[i].index > 1) {
                        y = rect.y + labelPadding + (elementSize.height * a) + (axis.opposedPosition ?
                            -(((elementSize.height * 0.5) / 2) * axis.multipleRow[i].index) :
                            (((elementSize.height * 0.5) / 2) * axis.multipleRow[i].index));
                    }
                    else {
                        y = rect.y + labelPadding + (axis.opposedPosition ? -((elementSize.height * 0.5) / 2) :
                            ((elementSize.height * 0.5) / 2));
                    }
                }
                else {
                    y = rect.y + ((axis.textStyle.textOverflow === 'Wrap' || isLineBreak) && axis.opposedPosition && angle % 360 === 0 ? -(axis.farSizes.length >= 1 ? axis.farSizes[1] : 0) + padding : labelPadding);
                }
                this.drawXAxisBorder(axis, borderElement, axis.rect, x, elementSize.width, i);
                x = (axis.textStyle.textAlignment === 'Center' && wrappedlabels.length > 1) ? x + (elementSize.width / 2) : axis.textStyle.textAlignment === 'Near' ? x + padding / 2 : axis.textStyle.textAlignment === 'Far' ? x - padding / 2 : x;
                if (angle % 360 !== 0) {
                    angle = (angle > 360) ? angle % 360 : angle;
                    rotateSize = helper_1.rotateTextSize(axis.textStyle, wrappedlabels, angle);
                    x = lableRect.x + (axis.isInversed ? -(lableRect.width / 2) : (lableRect.width / 2)) + (angle === 90 ? (elementSize.height * ((wrappedlabels.length - 1) / 2)) : angle === 270 ? -(elementSize.height * (wrappedlabels.length - 1) / 2) : 0);
                    y = y + (axis.opposedPosition ? (((axis.textStyle.textOverflow === 'Wrap' || isLineBreak) && !axis.enableTrim ? (((angle % 360) === 180) ? padding : 0) + (rotateSize.height / 2) - (axis.farSizes.length >= 1 ? axis.farSizes[1] : 0) : -(rotateSize.height / 2)) + (axis.border.width / 2)) :
                        (((angle % 360) === 0) ? 0 : ((angle % 360) === 180) ? (rotateSize.height / 2) - (axis.border.width) + padding : (rotateSize.height / 2) - (axis.border.width)));
                    if (wrappedlabels.length > 1) {
                        y = y - ((angle > 0 && angle < 80) || (angle > 300 && angle < 360) ? elementSize.height * ((wrappedlabels.length - 1) / 2) : (angle > 120 && angle < 240) && angle !== 180 && wrappedlabels.length > 2 ? -(elementSize.height * ((wrappedlabels.length - 2) / 2)) : 0);
                        x = x + ((angle > 0 && angle < 70) ? elementSize.height * ((wrappedlabels.length - 1) / 2) : 0);
                    }
                    transform = 'rotate(' + angle + ',' + x + ',' + y + ')';
                }
                if (this.heatMap.cellSettings.border.width > 5 && axis.opposedPosition) {
                    y = y - (this.heatMap.cellSettings.border.width / 2);
                }
                if (this.heatMap.yAxis.opposedPosition && this.heatMap.cellSettings.border.width > 5) {
                    x = x + (this.heatMap.cellSettings.border.width / 2);
                }
                if (this.heatMap.xAxis.isInversed && this.heatMap.cellSettings.border.width > 5) {
                    x = x - (this.heatMap.cellSettings.border.width / 2);
                }
                if (elementSize.width >= interval) {
                    x = axis.border.width ? x + (axis.border.width / 2) : x;
                }
                x = axis.textStyle.textAlignment === 'Near' ? x + (axis.border.width / 2) : axis.textStyle.textAlignment === 'Far' ?
                    x - (axis.border.width / 2) : x;
                x = (angle % 360 === 0) && axis.textStyle.textAlignment === 'Center' && elementSize.width > interval ? lableRect.x + ((!axis.isInversed) ?
                    (elementSize.width / 2) : -((elementSize.width / 2))) : x;
                var options = new helper_1.TextOption(heatMap.element.id + '_XAxis_Label' + i, new helper_2.TextBasic(x, y, (angle % 360 === 0) ? (axis.textStyle.textAlignment === 'Center' && wrappedlabels.length > 1) ? 'middle' : 'start' : 'middle', label, angle, transform), axis.textStyle, axis.textStyle.color || heatMap.themeStyle.axisLabel);
                options.text = isLineBreak ? wrappedlabels : helper_2.getTitle(options.text, axis.textStyle, lableRect.width - (axis.border.width / 2));
                Iif (angle !== 0 && this.heatMap.enableCanvasRendering) {
                    this.drawSvgCanvas.canvasDrawText(options, null, null, null, wrappedlabels, elementSize.height, true);
                }
                else {
                    if (axis.textStyle.textOverflow === 'Wrap' || isLineBreak) {
                        this.drawSvgCanvas.createWrapText(options, axis.textStyle, labelElement);
                    }
                    else {
                        this.drawSvgCanvas.createText(options, labelElement, label);
                    }
                }
                if (compactInterval === 0) {
                    var labelInterval = (axis.valueType === 'DateTime' && axis.showLabelOn !== 'None') ?
                        axis.dateTimeAxisLabelInterval[i] : axis.axisLabelInterval;
                    lableStrtX = lableStrtX + (!axis.isInversed ? (labelInterval * interval) :
                        -(labelInterval * interval));
                }
                else {
                    lableStrtX = lableStrtX + (!axis.isInversed ? (compactInterval * interval) : -(compactInterval * interval));
                }
                if (wrappedLabel.indexOf('...') !== -1) {
                    var xValue = axis.angle % 360 !== 0 ? x - (rotateSize.width / 2) : (axis.textStyle.textAlignment === 'Center' ? x - (elementSize.width / 2) : x);
                    var yValue = y - (axis.angle % 360 !== 0 ? (rotateSize.height / 2) : elementSize.height);
                    label = labels[i].indexOf('<br>') !== -1 || labels[i].indexOf('<br/>') !== -1 ? labels[i].replace(/<br\s*\/?>/g, ' ') : labels[i];
                    this.heatMap.tooltipCollection.push(new helper_1.CanvasTooltip(label, new helper_1.Rect(xValue, yValue, axis.angle % 360 !== 0 ? rotateSize.width : elementSize.width, axis.angle % 360 !== 0 ? rotateSize.height : elementSize.height * wrappedlabels.length)));
                }
                if (compactInterval !== 0) {
                    i = i + (compactInterval - 1);
                }
            }
            if (!heatMap.enableCanvasRendering) {
                parent.appendChild(labelElement);
                parent.appendChild(borderElement);
            }
        };
        AxisHelper.prototype.getWrappedLabels = function (wrappedLabel, labelInterval, axis) {
            var wrappedlabels = wrappedLabel.split(/<br\s*\/?>/, -1);
            for (var i = 0; i < wrappedlabels.length; i++) {
                var label = wrappedlabels[i];
                wrappedlabels[i] = helper_1.textTrim(labelInterval, label, axis.textStyle);
            }
            return wrappedlabels;
        };
        AxisHelper.prototype.getMaxLabel = function (wrappedlabels, axis) {
            var label = '';
            var labelWidth = 0;
            var wrappedlabelSize = new helper_1.Size(0, 0);
            for (var index = 0; index < wrappedlabels.length; index++) {
                wrappedlabelSize = helper_1.measureText(wrappedlabels[index], axis.textStyle);
                if (wrappedlabelSize.width > labelWidth) {
                    labelWidth = wrappedlabelSize.width;
                    label = wrappedlabels[index];
                }
            }
            return label;
        };
        AxisHelper.prototype.getLabels = function (label, labelInterval, axis, isLineBreak) {
            var wrappedlabels = [];
            if (isLineBreak) {
                wrappedlabels = this.getWrappedLabels(label, labelInterval, axis);
            }
            else {
                wrappedlabels = helper_1.textWrap(label, labelInterval, axis.textStyle);
            }
            return wrappedlabels;
        };
        AxisHelper.prototype.drawYAxisLabels = function (axis, parent, rect) {
            var heatMap = this.heatMap;
            var labels = axis.axisLabels;
            var interval = rect.height / axis.axisLabelSize;
            var compactInterval = 0;
            var tempintervel = rect.height / (axis.axisLabelSize / axis.axisLabelInterval);
            var temp = axis.axisLabelInterval;
            var label;
            if (tempintervel > 0) {
                while (tempintervel < parseInt(axis.textStyle.size, 10)) {
                    temp = temp + 1;
                    tempintervel = rect.height / (axis.axisLabelSize / temp);
                }
            }
            else {
                temp = axis.tooltipLabels.length;
            }
            if (axis.axisLabelInterval < temp) {
                compactInterval = temp;
                labels = axis.tooltipLabels;
            }
            var padding = 10;
            var labelPadding = 5;
            var lableStartY = rect.y + (axis.isInversed ? 0 : rect.height);
            var anchor = axis.opposedPosition ? 'start' : 'end';
            padding = axis.opposedPosition ? padding : -padding;
            var labelElement;
            var borderElement;
            if (!heatMap.enableCanvasRendering) {
                labelElement = this.heatMap.renderer.createGroup({ id: heatMap.element.id + 'YAxisLabels' });
                borderElement = this.heatMap.renderer.createGroup({ id: heatMap.element.id + 'YAxisLabelBorder' });
            }
            var isLineBreak = helper_1.getIsLineBreakLabel(labels);
            for (var i = 0, len = labels.length; i < len; i++) {
                var labelRect = new helper_1.Rect(rect.x, lableStartY, rect.width, interval);
                var position = axis.isInversed ? labelRect.height / 2 : -(labelRect.height / 2);
                var axisWidth = this.heatMap.cellSettings.border.width >= 20 ? (this.heatMap.cellSettings.border.width / 2) : 0;
                var indexValue = this.heatMap.cellSettings.border.width > 5 ?
                    (((this.heatMap.cellSettings.border.width / 2) / len) * (axis.isInversed ? (i) : (len - i))) : 0;
                label = (axis.enableTrim || axis.textStyle.textOverflow === 'Trim') && !isLineBreak ? helper_1.textTrim(axis.maxLabelLength, labels[i], axis.textStyle) : labels[i];
                var elementSize = helper_1.measureText(label, axis.textStyle);
                var labelLength = 1;
                var wrappedLabel = [];
                var rotateSize = new helper_1.Size(0, 0);
                if ((axis.textStyle.textOverflow === 'Wrap' || isLineBreak) && !axis.enableTrim) {
                    wrappedLabel = this.getLabels(label, axis.maxLabelLength, axis, isLineBreak);
                    for (var index = 0; index < wrappedLabel.length; index++) {
                        if ((elementSize.height * wrappedLabel.length) > (tempintervel + (labelPadding)) && wrappedLabel.length > 0 && (axis.angle !== 90 && axis.angle !== 270)) {
                            wrappedLabel.pop();
                            Eif (wrappedLabel.length > 0) {
                                wrappedLabel[wrappedLabel.length - 1] = wrappedLabel[wrappedLabel.length - 1] + '...';
                                wrappedLabel[wrappedLabel.length - 1] = helper_1.textTrim(axis.maxLabelLength, wrappedLabel[wrappedLabel.length - 1], axis.textStyle);
                            }
                        }
                    }
                    if (!(isLineBreak)) {
                        label = wrappedLabel.length !== 0 ? '' : label;
                        for (var labelIndex = 0; labelIndex < wrappedLabel.length; labelIndex++) {
                            label = ej2_base_1.isNullOrUndefined(label) ? wrappedLabel[labelIndex] : label + ' ' + wrappedLabel[labelIndex];
                        }
                    }
                    labelLength = wrappedLabel.length;
                }
                else {
                    if (isLineBreak && axis.enableTrim) {
                        wrappedLabel = this.getLabels(label, axis.maxLabelLength, axis, isLineBreak);
                        var trimmedLabel = helper_1.textTrim(axis.maxLabelLength, wrappedLabel[0], axis.textStyle);
                        label = (label.indexOf('<br>') !== -1 || label.indexOf('<br/>') !== -1) && trimmedLabel.indexOf('...') === -1 ? trimmedLabel + '...' : trimmedLabel;
                        wrappedLabel = [];
                    }
                    wrappedLabel.push(label);
                }
                var x = labelRect.x + padding + (axis.opposedPosition ? (axis.textStyle.textOverflow === 'Wrap' && axis.angle % 360 !== 0 ? labelLength * (elementSize.height / 2) : 0) + axisWidth : -axisWidth);
                if (axis.textStyle.textAlignment === 'Far' && axis.angle % 360 === 0) {
                    position = axis.isInversed ? labelRect.height - (labelLength > 1 ? (elementSize.height * labelLength) - (elementSize.height / 2) : (elementSize.height / 2)) :
                        -(labelLength > 1 ? (elementSize.height * labelLength) - (elementSize.height / 2) : (elementSize.height / 2));
                }
                else if (axis.textStyle.textAlignment === 'Near' && axis.angle % 360 === 0) {
                    position = (axis.isInversed ? elementSize.height / 2 : ((elementSize.height / 2) - labelRect.height)) + (axis.border.width / 2);
                }
                var y = (labelRect.y - indexValue) + position - ((labelLength > 1 && axis.textStyle.textAlignment === 'Center') || (axis.angle % 360 !== 0 && axis.opposedPosition) ? (((elementSize.height * labelLength) / 2) - (elementSize.height / 2)) : 0);
                if (axis.angle % 360 !== 0) {
                    anchor = 'middle';
                    axis.angle = (axis.angle > 360) ? axis.angle % 360 : axis.angle;
                    rotateSize = helper_1.rotateTextSize(axis.textStyle, wrappedLabel, axis.angle);
                    x = labelRect.x + (axis.opposedPosition ? (rotateSize.width / 2 + padding) : -(rotateSize.width / 2 - padding)) + (axis.angle === 90 ? (elementSize.height * ((wrappedLabel.length - 1) / 2)) : axis.angle === 270 ? -(elementSize.height * (wrappedLabel.length - 1) / 2) : 0);
                    y = labelRect.y + (axis.isInversed ? (labelRect.height / 2) : (-labelRect.height / 2)) + (axis.angle === 180 ? (elementSize.height * ((wrappedLabel.length - 1) / 2)) : 0);
                    if (wrappedLabel.length > 1) {
                        var value = elementSize.height * ((wrappedLabel.length - 1) / 2);
                        y = y - ((axis.angle > 0 && axis.angle < 60) || (axis.angle > 290 && axis.angle < 360) ? value : (axis.angle > 115 && axis.angle < 240) && axis.angle !== 180 ? -value : 0);
                        x = x + (axis.angle > 20 && axis.angle < 160 && axis.angle !== 90 ? value : axis.angle > 200 && axis.angle < 330 && axis.angle !== 270 ? -value - (axis.angle > 200 && axis.angle < 240 && !axis.opposedPosition && wrappedLabel.length > 2 ? -(elementSize.height * ((wrappedLabel.length - 2) / 2)) : 0) :
                            (axis.angle >= 330 && axis.angle < 350 ? -value / 2 : 0));
                    }
                }
                var options = new helper_1.TextOption(heatMap.element.id + '_YAxis_Label' + i, new helper_2.TextBasic(x, y, anchor, label, axis.angle, 'rotate(' + axis.angle + ',' + (x) + ',' + (y) + ')', 'middle'), axis.textStyle, axis.textStyle.color || heatMap.themeStyle.axisLabel);
                Iif (ej2_base_1.Browser.isIE && !heatMap.enableCanvasRendering) {
                    options.dy = '1ex';
                }
                options.text = isLineBreak ? wrappedLabel : helper_2.getTitle(options.text, axis.textStyle, axis.maxLabelLength);
                Iif (axis.angle !== 0 && this.heatMap.enableCanvasRendering) {
                    this.drawSvgCanvas.canvasDrawText(options, null, null, null, wrappedLabel, elementSize.height, true);
                }
                else {
                    if (axis.textStyle.textOverflow === 'Wrap' || isLineBreak) {
                        this.drawSvgCanvas.createWrapText(options, axis.textStyle, labelElement);
                    }
                    else {
                        this.drawSvgCanvas.createText(options, labelElement, label);
                    }
                }
                if (compactInterval === 0) {
                    var labelInterval = (axis.valueType === 'DateTime' && axis.showLabelOn !== 'None') ?
                        axis.dateTimeAxisLabelInterval[i] : axis.axisLabelInterval;
                    lableStartY = lableStartY + (axis.isInversed ? (labelInterval * interval) :
                        -(labelInterval * interval));
                }
                else {
                    lableStartY = lableStartY + (axis.isInversed ? (compactInterval * interval) : -(compactInterval * interval));
                    i = i + (compactInterval - 1);
                }
                this.drawYAxisBorder(axis, borderElement, axis.rect, y, elementSize.height, i);
                label = this.getMaxLabel(wrappedLabel, axis);
                if (label.indexOf('...') !== -1) {
                    var xValue = axis.opposedPosition ? x : (x - (axis.angle % 360 !== 0 ? (rotateSize.width / 2) : elementSize.width));
                    var yValue = y - (axis.angle % 360 !== 0 ? (rotateSize.height / 2) : elementSize.height);
                    label = labels[i].indexOf('<br>') !== -1 || labels[i].indexOf('<br/>') !== -1 ? labels[i].replace(/<br\s*\/?>/g, ' ') : labels[i];
                    this.heatMap.tooltipCollection.push(new helper_1.CanvasTooltip(label, new helper_1.Rect(xValue, yValue, (axis.angle % 360 !== 0 ? rotateSize.width : elementSize.width), (axis.angle % 360 !== 0 ? rotateSize.height : elementSize.height * wrappedLabel.length))));
                }
            }
            if (!heatMap.enableCanvasRendering) {
                parent.appendChild(labelElement);
                parent.appendChild(borderElement);
            }
        };
        AxisHelper.prototype.drawXAxisBorder = function (axis, parent, rect, lableX, width, index) {
            var interval = rect.width / axis.axisLabelSize;
            var path = '';
            var padding = 10;
            var axisInterval = axis.interval ? axis.interval : 1;
            var startX = axis.isInversed ? rect.x + rect.width - (interval * index * axisInterval) :
                rect.x + (interval * index * axisInterval);
            var startY = rect.y;
            var endX;
            var endY;
            endY = startY + (axis.opposedPosition ? -(axis.maxLabelSize.height + padding) : axis.maxLabelSize.height + padding);
            endX = axis.isInversed ? startX - interval : startX + interval;
            var endY1 = axis.isInversed ? (lableX + width + padding) : (lableX - padding);
            var endY2 = axis.isInversed ? (lableX - padding) : (lableX + width + padding);
            endY2 = axis.textStyle.textAlignment === 'Near' && axis.isInversed ? endY2 + padding : axis.textStyle.textAlignment === 'Far' && !axis.isInversed ? endY2 - padding : endY2;
            endY1 = axis.textStyle.textAlignment === 'Far' && axis.isInversed ? endY1 - padding : axis.textStyle.textAlignment === 'Near' && !axis.isInversed ? endY1 + padding : endY1;
            switch (axis.border.type) {
                case 'Rectangle':
                    path = ('M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + startY);
                    break;
                case 'WithoutTopBorder':
                    path = 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ';
                    break;
                case 'WithoutBottomBorder':
                    path = 'M' + ' ' + startX + ' ' + endY + ' ' + 'L' + ' ' + startX + ' ' + startY + ' ' +
                        'L' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ';
                    break;
                case 'WithoutTopandBottomBorder':
                    path = 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'M' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ';
                    break;
                case 'Brace':
                    endY = startY + ((endY - startY) / 2) + (axis.opposedPosition ? 0 : 5);
                    path = 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'L' + ' ' + endY1 + ' ' + endY + ' ' + 'M' + ' ' + endY2 +
                        ' ' + endY + ' ' + 'L' +
                        ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ';
                    break;
            }
            if (axis.border.width > 0 && axis.border.type !== 'WithoutBorder') {
                this.createAxisBorderElement(axis, path, parent, index);
            }
        };
        AxisHelper.prototype.drawYAxisBorder = function (axis, parent, rect, lableY, height, index) {
            var interval = rect.height / axis.axisLabelSize;
            var path = '';
            var padding = 20;
            var axisInterval = axis.interval ? axis.interval : 1;
            var startX = rect.x;
            var startY = axis.isInversed ? rect.y + (interval * index * axisInterval) :
                rect.y + rect.height - (interval * index * axisInterval);
            var endX;
            var endY;
            endX = startX + (!axis.opposedPosition ? -(axis.maxLabelSize.width + padding) : axis.maxLabelSize.width + padding);
            endY = axis.isInversed ? startY + interval : startY - interval;
            var endY1 = axis.isInversed ? lableY - height / 2 : lableY + height / 2;
            var endY2 = axis.isInversed ? lableY + height / 2 : lableY - height / 2;
            switch (axis.border.type) {
                case 'Rectangle':
                    path = 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + startY;
                    break;
                case 'WithoutTopBorder':
                    path = 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ';
                    break;
                case 'WithoutBottomBorder':
                    path = 'M' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + startY + ' ' +
                        'L' + ' ' + startX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ';
                    break;
                case 'WithoutTopandBottomBorder':
                    path = 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' +
                        'M' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ';
                    break;
                case 'Brace':
                    endX = startX - (startX - endX) / 2;
                    path = 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' +
                        'L' + ' ' + endX + ' ' + endY1 + ' ' + 'M' + ' ' +
                        endX + ' ' + endY2 + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ' +
                        'L' + ' ' + startX + ' ' + endY;
                    break;
            }
            if (axis.border.width > 0 && axis.border.type !== 'WithoutBorder') {
                this.createAxisBorderElement(axis, path, parent, index);
            }
        };
        AxisHelper.prototype.createAxisBorderElement = function (axis, labelBorder, parent, index) {
            var canvasTranslate;
            var id = axis.orientation === 'Horizontal' ? '_XAxis_Label_Border' : '_YAxis_Label_Border';
            var pathOptions = new helper_1.PathOption(this.heatMap.element.id + id + index, 'transparent', axis.border.width, axis.border.color, 1, 'none', labelBorder);
            if (!this.heatMap.enableCanvasRendering) {
                var borderElement = this.heatMap.renderer.drawPath(pathOptions);
                parent.appendChild(borderElement);
            }
            else {
                this.heatMap.canvasRenderer.drawPath(pathOptions, canvasTranslate);
            }
        };
        AxisHelper.prototype.drawMultiLevels = function (parent, axis) {
            var element;
            if (!this.heatMap.enableCanvasRendering) {
                element = this.heatMap.renderer.createGroup({ id: this.heatMap.element.id + '_' + axis.orientation + '_MultiLevelLabel' });
            }
            if (axis.orientation === 'Horizontal') {
                this.renderXAxisMultiLevelLabels(axis, element);
            }
            else {
                this.renderYAxisMultiLevelLabels(axis, element);
            }
            if (!this.heatMap.enableCanvasRendering) {
                parent.appendChild(element);
            }
        };
        AxisHelper.prototype.renderXAxisMultiLevelLabels = function (axis, parent) {
            var _this = this;
            var x = 0;
            var y;
            var padding = 10;
            var startX;
            var startY;
            var endX = 0;
            var tooltip;
            var start;
            var end;
            var labelSize;
            var anchor;
            var isInversed = axis.isInversed;
            var labelElement;
            var opposedPosition = axis.opposedPosition;
            var pathRect = '';
            var gap;
            var textLength;
            var position = (isInversed ? axis.rect.width : 0) + axis.rect.x;
            axis.multiLevelLabels.map(function (multiLevel, level) {
                labelElement = _this.heatMap.renderer.createGroup({ id: _this.heatMap.element.id + '_XAxisMultiLevelLabel' + level });
                multiLevel.categories.map(function (categoryLabel, i) {
                    if (!ej2_base_1.isNullOrUndefined(categoryLabel.start) && !ej2_base_1.isNullOrUndefined(categoryLabel.end)) {
                        Iif (_this.heatMap.theme === 'Tailwind' || _this.heatMap.theme === 'TailwindDark') {
                            multiLevel.setProperties({ textStyle: { fontFamily: 'Inter' } }, true);
                        }
                        if (_this.heatMap.theme === 'Material3' || _this.heatMap.theme === 'Material3Dark') {
                            multiLevel.setProperties({ textStyle: { fontFamily: 'Roboto' } }, true);
                        }
                        Iif (_this.heatMap.theme === 'Fluent' || _this.heatMap.theme === 'FluentDark') {
                            multiLevel.setProperties({ textStyle: { fontFamily: '"Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", "Helvetica Neue", sans-serif' } }, true);
                        }
                        if (_this.heatMap.theme === 'Fluent2') {
                            multiLevel.setProperties({ textStyle: { color: '#242424', size: '12px', fontWeight: '400', fontFamily: 'Segoe UI' } }, true);
                        }
                        if (_this.heatMap.theme === 'Fluent2Dark' || _this.heatMap.theme === 'Fluent2HighContrast') {
                            multiLevel.setProperties({ textStyle: { color: '#FFFFFF', size: '12px', fontWeight: '400', fontFamily: 'Segoe UI' } }, true);
                        }
                        Iif (_this.heatMap.theme === 'Bootstrap5') {
                            multiLevel.setProperties({ textStyle: { color: '#212529', size: '12px', fontWeight: '400', fontFamily: 'Segoe UI' } }, true);
                        }
                        Iif (_this.heatMap.theme === 'Bootstrap5Dark') {
                            multiLevel.setProperties({ textStyle: { color: '#DEE2E6', size: '12px', fontWeight: '400', fontFamily: 'Segoe UI' } }, true);
                        }
                        tooltip = false;
                        start = typeof categoryLabel.start === 'number' ? categoryLabel.start : Number(new Date(categoryLabel.start));
                        end = typeof categoryLabel.end === 'number' ? categoryLabel.end : Number(new Date(categoryLabel.end));
                        startX = position + _this.calculateLeftPosition(axis, start, categoryLabel.start, axis.rect);
                        startY = axis.multiLevelPosition[level].y;
                        endX = position + _this.calculateWidth(axis, categoryLabel.end, end, axis.rect);
                        labelSize = helper_1.measureText(categoryLabel.text, multiLevel.textStyle);
                        gap = ((categoryLabel.maximumTextWidth === null) ? Math.abs(endX - startX) : categoryLabel.maximumTextWidth) - padding;
                        y = startY + (opposedPosition ? -((axis.xAxisMultiLabelHeight[level] - labelSize.height)) : labelSize.height);
                        x = !isInversed ? startX + padding : startX - gap;
                        if (multiLevel.alignment === 'Center') {
                            x = ((endX - startX) / 2) + startX;
                            x -= (labelSize.width > gap ? gap : labelSize.width) / 2;
                        }
                        else if (multiLevel.alignment === 'Far') {
                            x = !isInversed ? endX - padding : startX - padding;
                            x -= (labelSize.width > gap ? gap : labelSize.width);
                        }
                        else {
                            x = !isInversed ? startX + padding : endX + padding;
                        }
                        if (multiLevel.overflow === 'None' && labelSize.width > Math.abs(endX - startX)) {
                            x = !isInversed ? startX + padding : startX - labelSize.width - padding;
                            anchor = 'start';
                        }
                        var textBasic = new helper_2.TextBasic(x, y, anchor, categoryLabel.text, 0, 'translate(0,0)');
                        var options = new helper_1.TextOption(_this.heatMap.element.id + '_XAxis_MultiLevel' + level + '_Text' + i, textBasic, multiLevel.textStyle, multiLevel.textStyle.color || _this.heatMap.themeStyle.axisLabel);
                        if (multiLevel.overflow === 'Wrap') {
                            options.text = helper_1.textWrap(categoryLabel.text, gap, multiLevel.textStyle);
                            textLength = options.text.length;
                        }
                        else if (multiLevel.overflow === 'Trim') {
                            options.text = helper_1.textTrim(gap, categoryLabel.text, multiLevel.textStyle);
                            textLength = 1;
                        }
                        if (multiLevel.overflow === 'Wrap' && options.text.length > 1) {
                            _this.drawSvgCanvas.createWrapText(options, multiLevel.textStyle, labelElement);
                            for (var i_2 = 0; i_2 < options.text.length; i_2++) {
                                Eif (options.text[i_2].indexOf('...') !== -1) {
                                    tooltip = true;
                                    break;
                                }
                            }
                        }
                        else {
                            _this.drawSvgCanvas.createText(options, labelElement, options.text);
                        }
                        if (!_this.heatMap.enableCanvasRendering) {
                            parent.appendChild(labelElement);
                        }
                        if (options.text.indexOf('...') !== -1 || options.text[0].indexOf('...') !== -1 || tooltip) {
                            _this.heatMap.tooltipCollection.push(new helper_1.CanvasTooltip(categoryLabel.text, new helper_1.Rect(x, y - labelSize.height, gap, labelSize.height * textLength)));
                        }
                        Eif (multiLevel.border.width > 0 && multiLevel.border.type !== 'WithoutBorder') {
                            pathRect = _this.renderXAxisLabelBorder(level, axis, startX, startY, endX, pathRect, level, labelSize, gap, x);
                        }
                    }
                });
                Eif (pathRect !== '') {
                    _this.createBorderElement(level, axis, pathRect, parent);
                    pathRect = '';
                }
            });
            if (!this.heatMap.enableCanvasRendering) {
                parent.appendChild(labelElement);
            }
        };
        AxisHelper.prototype.renderXAxisLabelBorder = function (labelIndex, axis, startX, startY, endX, path, level, labelSize, gap, x) {
            var path1;
            var path2;
            var endY = startY + (axis.opposedPosition ? -(axis.xAxisMultiLabelHeight[labelIndex]) :
                axis.xAxisMultiLabelHeight[labelIndex]);
            var padding = 3;
            switch (axis.multiLevelLabels[level].border.type) {
                case 'Rectangle':
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + startY + ' ';
                    break;
                case 'WithoutTopBorder':
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ';
                    break;
                case 'WithoutBottomBorder':
                    path += 'M' + ' ' + startX + ' ' + endY + ' ' + 'L' + ' ' + startX + ' ' + startY + ' ' +
                        'L' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ';
                    break;
                case 'WithoutTopandBottomBorder':
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' +
                        'M' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ';
                    break;
                case 'Brace':
                    path1 = axis.isInversed ? (labelSize.width > gap ? gap : labelSize.width) + x + padding : x - padding;
                    path2 = axis.isInversed ? x - padding : (labelSize.width > gap ? gap : labelSize.width) + x + padding;
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + (startY + (endY - startY) / 2) + ' ' +
                        'L' + ' ' + path1 + ' ' + (startY + (endY - startY) / 2) + ' ' + 'M' + ' ' + path2 + ' ' + (startY +
                        (endY - startY) / 2) + ' ' + 'L' + ' ' + endX + ' ' + (startY + (endY - startY) / 2) +
                        ' ' + 'L' + ' ' + endX + ' ' + startY + ' ';
                    break;
            }
            return path;
        };
        AxisHelper.prototype.renderYAxisMultiLevelLabels = function (axis, parent) {
            var _this = this;
            var x = 0;
            var y;
            var padding = 10;
            var startX;
            var startY;
            var endY;
            var start;
            var end;
            var labelSize;
            var isInversed = axis.isInversed;
            var labelElement;
            var pathRect = '';
            var gap;
            var text;
            var position = (!isInversed ? axis.rect.height : 0) + axis.rect.y;
            axis.multiLevelLabels.map(function (multiLevel, level) {
                startY = axis.multiLevelPosition[level].y;
                labelElement = _this.heatMap.renderer.createGroup({ id: _this.heatMap.element.id + '_YAxisMultiLevelLabel' + level });
                multiLevel.categories.map(function (categoryLabel, i) {
                    Iif (_this.heatMap.theme === 'Tailwind' || _this.heatMap.theme === 'TailwindDark') {
                        multiLevel.setProperties({ textStyle: { fontFamily: 'Inter' } }, true);
                    }
                    if (_this.heatMap.theme === 'Material3' || _this.heatMap.theme === 'Material3Dark') {
                        multiLevel.setProperties({ textStyle: { fontFamily: 'Roboto' } }, true);
                    }
                    Iif (_this.heatMap.theme === 'Bootstrap5' || _this.heatMap.theme === 'Bootstrap5Dark') {
                        multiLevel.setProperties({ textStyle: { fontFamily: 'Segoe UI' } }, true);
                    }
                    if (_this.heatMap.theme === 'Fluent2') {
                        multiLevel.setProperties({ textStyle: { color: '#242424', size: '12px', fontWeight: '400', fontFamily: 'Segoe UI' } }, true);
                    }
                    if (_this.heatMap.theme === 'Fluent2Dark' || _this.heatMap.theme === 'Fluent2HighContrast') {
                        multiLevel.setProperties({ textStyle: { color: '#FFFFFF', size: '12px', fontWeight: '400', fontFamily: 'Segoe UI' } }, true);
                    }
                    start = typeof categoryLabel.start === 'number' ? categoryLabel.start : Number(new Date(categoryLabel.start));
                    end = typeof categoryLabel.end === 'number' ? categoryLabel.end : Number(new Date(categoryLabel.end));
                    startY = position + _this.calculateLeftPosition(axis, start, categoryLabel.start, axis.rect);
                    startX = axis.multiLevelPosition[level].x;
                    endY = position + _this.calculateWidth(axis, categoryLabel.start, end, axis.rect);
                    labelSize = helper_1.measureText(categoryLabel.text, multiLevel.textStyle);
                    gap = ((categoryLabel.maximumTextWidth === null) ? Math.abs(startX) : categoryLabel.maximumTextWidth) - padding;
                    var maxWidth = Math.abs(startX - (startX - axis.multiLevelSize[level].width - 2 * padding)) / 2 -
                        (labelSize.width / 2);
                    x = (axis.opposedPosition ? startX : startX - axis.multiLevelSize[level].width - 2 * padding) + maxWidth;
                    y = startY + padding;
                    Eif (multiLevel.overflow !== 'None') {
                        if (multiLevel.overflow === 'Wrap') {
                            text = helper_1.textWrap(categoryLabel.text, gap, multiLevel.textStyle);
                        }
                        else {
                            text = helper_1.textTrim(gap, categoryLabel.text, multiLevel.textStyle);
                        }
                    }
                    if (multiLevel.alignment === 'Center') {
                        y += ((endY - startY) / 2 - (text.length * labelSize.height) / 2);
                    }
                    else if (multiLevel.alignment === 'Far') {
                        y = isInversed ? endY - labelSize.height / 2 : y - labelSize.height;
                    }
                    else {
                        y = isInversed ? y + labelSize.height / 2 : endY + labelSize.height;
                    }
                    Eif (multiLevel.border.width > 0 && multiLevel.border.type !== 'WithoutBorder') {
                        pathRect = _this.renderYAxisLabelBorder(level, axis, startX, startY, endY, pathRect, level, labelSize, gap, y);
                    }
                    var textBasic = new helper_2.TextBasic(x, y, 'start', categoryLabel.text, 0, 'translate(0,0)');
                    var options = new helper_1.TextOption(_this.heatMap.element.id + '_YAxis_MultiLevel' + level + '_Text' + i, textBasic, multiLevel.textStyle, multiLevel.textStyle.color || _this.heatMap.themeStyle.axisLabel);
                    options.text = text;
                    _this.drawSvgCanvas.createText(options, labelElement, options.text);
                    if (options.text.indexOf('...') !== -1) {
                        _this.heatMap.tooltipCollection.push(new helper_1.CanvasTooltip(categoryLabel.text, new helper_1.Rect(x, y - labelSize.height, gap, labelSize.height)));
                    }
                    Eif (!_this.heatMap.enableCanvasRendering) {
                        parent.appendChild(labelElement);
                    }
                });
                Eif (pathRect !== '') {
                    _this.createBorderElement(level, axis, pathRect, parent);
                    pathRect = '';
                }
            });
            Eif (!this.heatMap.enableCanvasRendering) {
                parent.appendChild(labelElement);
            }
        };
        AxisHelper.prototype.renderYAxisLabelBorder = function (labelIndex, axis, startX, startY, endY, path, level, labelSize, gap, y) {
            var padding = 20;
            var path1;
            var path2;
            var endX = startX - (axis.opposedPosition ? -(axis.multiLevelSize[labelIndex].width + padding) :
                (axis.multiLevelSize[labelIndex].width + padding));
            switch (axis.multiLevelLabels[level].border.type) {
                case 'Rectangle':
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ' + 'L' + ' ' + startX + ' ' + startY + ' ';
                    break;
                case 'WithoutTopBorder':
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' +
                        'L' + ' ' + endX + ' ' + endY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ';
                    break;
                case 'WithoutBottomBorder':
                    path += 'M' + ' ' + endX + ' ' + startY + ' ' + 'L' + ' ' + startX + ' ' + startY + ' ' +
                        'L' + ' ' + startX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ';
                    break;
                case 'WithoutTopandBottomBorder':
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + endX + ' ' + startY + ' ' +
                        'M' + ' ' + startX + ' ' + endY + ' ' + 'L' + ' ' + endX + ' ' + endY + ' ';
                    break;
                case 'Brace':
                    padding = 10;
                    path1 = axis.isInversed ? (y - padding - 5) : (y + (labelSize.height) - padding);
                    path2 = axis.isInversed ? (y + (labelSize.height) - padding) : (y - padding - 5);
                    path += 'M' + ' ' + startX + ' ' + startY + ' ' + 'L' + ' ' + (startX + (endX - startX) / 2) + ' ' + startY + ' ' +
                        'L' + ' ' + (startX + (endX - startX) / 2) + ' ' + path1 + ' ' + 'M' + ' ' + (startX + (endX - startX) / 2) +
                        ' ' + path2 + ' ' + 'L' + ' ' + (startX + (endX - startX) / 2) + ' ' +
                        endY + ' ' + 'L' + ' ' + startX + ' ' + endY + ' ';
                    break;
            }
            return path;
        };
        AxisHelper.prototype.createBorderElement = function (borderIndex, axis, path, parent) {
            var canvasTranslate;
            var id = axis.orientation === 'Horizontal' ? 'XAxis' : 'YAxis';
            var pathOptions = new helper_1.PathOption(this.heatMap.element.id + '_' + id + '_MultiLevel_Rect_' + borderIndex, 'Transparent', axis.multiLevelLabels[borderIndex].border.width, axis.multiLevelLabels[borderIndex].border.color, 1, '', path);
            var borderElement = this.heatMap.renderer.drawPath(pathOptions);
            if (!this.heatMap.enableCanvasRendering) {
                parent.appendChild(borderElement);
            }
            else {
                this.heatMap.canvasRenderer.drawPath(pathOptions, canvasTranslate);
            }
        };
        AxisHelper.prototype.calculateLeftPosition = function (axis, start, label, rect) {
            var value;
            var interval;
            if (typeof label === 'number') {
                if (axis.valueType === 'Numeric' && (axis.minimum || axis.maximum)) {
                    var min = axis.minimum ? axis.minimum : 0;
                    start -= min;
                }
                var size = axis.orientation === 'Horizontal' ? rect.width : rect.height;
                interval = size / (axis.axisLabelSize * axis.increment);
                value = (axis.isInversed ? -1 : 1) * start * interval;
                value = axis.orientation === 'Horizontal' ? value : -value;
            }
            else {
                interval = this.calculateNumberOfDays(start, axis, true, rect);
                value = axis.isInversed ? -interval : interval;
                value = axis.orientation === 'Horizontal' ? value : -value;
            }
            return value;
        };
        AxisHelper.prototype.calculateWidth = function (axis, label, end, rect) {
            var interval;
            var value;
            if (typeof label === 'number') {
                if (axis.valueType === 'Numeric' && (axis.minimum || axis.maximum)) {
                    var min = axis.minimum ? axis.minimum : 0;
                    end -= min;
                }
                var size = axis.orientation === 'Horizontal' ? rect.width : rect.height;
                interval = size / (axis.axisLabelSize * axis.increment);
                value = (axis.isInversed ? -1 : 1) * (end + 1) * interval;
                value = axis.orientation === 'Horizontal' ? value : -value;
            }
            else {
                interval = this.calculateNumberOfDays(end, axis, false, rect);
                value = interval;
                value = axis.isInversed ? -value : value;
                value = axis.orientation === 'Horizontal' ? value : -value;
            }
            return value;
        };
        AxisHelper.prototype.calculateNumberOfDays = function (date, axis, start, rect) {
            var oneDay = 24 * 60 * 60 * 1000;
            var oneMinute = 60 * 1000;
            var firstDate;
            var secondDate;
            var labels = axis.labelValue;
            var position;
            var interval = (axis.orientation === 'Horizontal' ? rect.width : rect.height) / axis.axisLabelSize;
            var givenDate = new Date(Number(date));
            var days = 0;
            for (var index = 0; index < axis.axisLabelSize; index++) {
                firstDate = new Date(Number(labels[index]));
                secondDate = axis.isInversed ? new Date(Number(labels[index - 1])) : new Date(Number(labels[index + 1]));
                if (index === (axis.isInversed ? 0 : axis.axisLabelSize - 1)) {
                    secondDate = new Date(Number(labels[index]));
                    if (axis.intervalType === 'Hours') {
                        secondDate = new Date(Number(secondDate.setHours(secondDate.getHours() + 1)));
                    }
                    else if ((axis.intervalType === 'Minutes')) {
                        secondDate = new Date(Number(secondDate.setMinutes(secondDate.getMinutes() + 1)));
                    }
                    else if ((axis.intervalType === 'Days')) {
                        secondDate = new Date(Number(secondDate.setDate(secondDate.getDate() + 1)));
                    }
                    else {
                        var numberOfDays = axis.intervalType === 'Months' ?
                            new Date(secondDate.getFullYear(), secondDate.getMonth() + 1, 0).getDate() :
                            secondDate.getFullYear() % 4 === 0 ? 366 : 365;
                        secondDate = new Date(Number(secondDate.setDate(secondDate.getDate() + numberOfDays)));
                    }
                }
                if (Number(firstDate) <= date && Number(secondDate) >= date) {
                    if (axis.intervalType === 'Minutes' || axis.intervalType === 'Hours') {
                        var totalMinutes = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime()) / (oneMinute)));
                        var minutesInHours = Math.abs((firstDate.getTime() - givenDate.getTime()) / (oneMinute));
                        days = (interval / totalMinutes) * minutesInHours;
                        index = axis.isInversed ? axis.axisLabelSize - 1 - index : index;
                        position = index * interval + days;
                        break;
                    }
                    else {
                        var numberOfDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime()) / (oneDay)));
                        start ? givenDate.getDate() : givenDate.setDate(givenDate.getDate() + 1);
                        Eif (numberOfDays !== 0) {
                            days = (interval / numberOfDays) * (Math.abs((firstDate.getTime() - givenDate.getTime()) / (oneDay)));
                        }
                        index = axis.isInversed ? axis.axisLabelSize - 1 - index : index;
                        position = index * interval + days;
                        break;
                    }
                }
            }
            return position;
        };
        AxisHelper.prototype.destroy = function () {
            this.drawSvgCanvas = null;
            this.element = null;
            this.htmlObject = null;
            this.initialClipRect = null;
            this.heatMap = null;
        };
        return AxisHelper;
    }());
    exports.AxisHelper = AxisHelper;
});