all files / pivotchart/base/ pivotchart.js

76.49% Statements 768/1004
62.64% Branches 741/1183
67.74% Functions 42/62
76.47% Lines 767/1003
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 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786   33× 33× 33× 33× 33× 33× 33× 33× 33× 33×   1809×   204× 204× 204× 204× 204× 204×                 204× 203× 17×   203× 34×     186×   203× 406× 406× 406× 406× 406×                                                     203× 203× 203× 203×   328×   203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 406× 406× 406× 406×   203× 18× 18× 18× 18×   18×   203× 3333× 3333× 3333× 3333× 3333×   3333× 3333× 2676×   265×   2676× 2411× 2919× 2919× 153× 153×     2411×     3333×   2533× 2533×     2533×   2533× 2533× 2533× 1091× 1091× 1091× 1091×   1091× 1091× 1091× 1091×           1091× 1091× 1091×   1091× 1091× 1091×     1442× 1307× 978×   1307×   2533× 2533×   2533× 2533×   2533×   2533× 2533×                       2533× 2398× 144×     2254× 2254×     2533× 2533× 2533× 2533× 1091×     1442× 1442× 1307×     135×   135× 135× 135× 135×   135×     135×                               2533× 30705× 30705× 30705× 30705× 30705×   30705×   11042× 1025×   11042×               144×   10898×     10898× 10898× 5541×     5357× 5357×   10898× 10898× 5541×     5357× 5357×   10898× 10898× 10898×   10898×         10898× 10898× 1694×   10898× 10048×               850×               30561×         203×   204× 204× 204× 204× 204× 204×   204× 204×   204× 204× 204× 408×       204× 19× 19× 19× 19×       19× 19× 19× 19× 17× 17×       19×     19×   19× 19×       19× 19×   19×     185× 782× 782× 782× 782×         782× 10545× 10545×     782× 782× 782× 782× 782× 782× 782× 782× 1564× 782× 782×     782× 280× 280×   280×   782× 782× 16× 16× 16× 16×         782× 774× 774× 774×     782×     782× 782×   782×     204× 204× 204× 204× 203×             358× 358× 358× 358× 598× 598×   358×   801× 801× 801× 801× 1573×                 1573× 1573×   801×   203× 203× 203× 203× 203× 203× 203× 203× 168×                   35×       203×       203×   203× 175×     28×   203× 203× 163×   203× 203×         203×                     203×   31×                     31× 31× 31×                                                                                             29×                                                                                                                                                       31×     172× 172× 172× 172× 172× 172× 172× 172× 172× 172× 172× 172× 172× 17× 17× 17×     155× 155× 155× 155× 155× 155×   172×   170× 153× 153× 153× 153×     152×         152× 152×     172× 172×             203×     198×                                                                       203× 203× 203× 203× 203×       203×   203× 17× 17× 17× 34× 34× 34×   34× 34× 34× 30× 30× 15× 15×     34×     34× 34× 34× 34×   34×   34×   34×   34×       32×   34× 34×     34× 34×     34× 34× 34× 34× 34×               34×       186× 186×     186× 186× 239× 239× 156× 156×     186× 186× 156×   186× 186×     186× 186×   186× 186× 186×   186× 184×   186× 186× 186× 186× 186×   203×                   239× 239× 239× 747× 747× 747× 747× 747× 747× 5341× 5341× 5341× 5341× 239×   5102×   664×               18× 18× 18× 18× 18× 18× 1153× 1153× 1091× 18×                   18× 18×   18×     1073×       18× 18× 18× 18×       18×     18×   203× 203× 203× 2254× 2254× 2254× 2254× 2254× 2254× 2755× 2548× 294×     2254×     207× 63×                         2755×   2254×   203× 203× 2254× 2254× 2254× 2254× 2254× 2755× 2755× 2755× 2493× 2493× 294×     2199×               262×             2254×   203× 203× 203× 262×   203×   204× 204× 204×   204× 204×   281× 158×   123× 26×   97×     96×   281×   203×   203× 203×     203×     203× 203× 203×   203× 203×     203× 203× 203× 203×   203× 203× 203× 203× 203×   322×   203×   203×   203× 203× 203× 203×             203×   203× 203×   203× 203×                                                                                                                                                     424× 424× 424×   50×   424× 424×   424× 371×     424× 424× 424× 11×       11× 11×   11× 11×   424× 424× 108×   424× 424× 424×     424× 352× 352× 352× 323× 323× 323× 303× 303× 303×         303× 303×     323×       29× 29× 29× 25× 25×   25× 25× 25×           29×                                                                                                                                                                                                                                                                                                             661× 661× 661×       661× 661× 661×   661× 661× 661× 472× 472×   661× 509×         152× 39×     113× 69×     44×     661× 472×           661×                                       18403× 18403× 3122×     18403× 15281×   15281×   15281×     15281×   18403×                                                                                                                   1091× 1091× 2838×                                   1091×   383× 347×   383×       69×   1643×   80×   6928×   1446×                                             4807×                               33×     33× 32× 32×   33× 31×   33× 33×   33× 33× 33×   33× 32×   33× 32×   33×       33×         33×          
define(["require", "exports", "../../common/base/constant", "../../common/base/css-constant", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-charts", "@syncfusion/ej2-base", "../../base/util", "@syncfusion/ej2-navigations", "@syncfusion/ej2-popups", "@syncfusion/ej2-data"], function (require, exports, events, cls, ej2_charts_1, ej2_charts_2, ej2_charts_3, ej2_charts_4, ej2_charts_5, ej2_charts_6, ej2_charts_7, ej2_charts_8, ej2_charts_9, ej2_charts_10, ej2_base_1, util_1, ej2_navigations_1, ej2_popups_1, ej2_data_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PivotChart = (function () {
        function PivotChart(parent) {
            this.headerColl = {};
            this.maxLevel = 0;
            this.columnGroupObject = {};
            this.selectedLegend = 0;
            this.chartSeriesInfo = {};
            this.measurePos = -1;
            this.measuresNames = {};
            this.accumulationType = ['Pie', 'Pyramid', 'Doughnut', 'Funnel'];
            this.isChartInitial = true;
            this.parent = parent;
        }
        PivotChart.prototype.getModuleName = function () {
            return 'pivotChart';
        };
        PivotChart.prototype.loadChart = function (parent, chartSettings) {
            this.parent = parent;
            this.measuresNames = {};
            this.engineModule = this.parent.dataType === 'olap' ? this.parent.olapEngineModule : this.parent.engineModule;
            this.dataSourceSettings = this.parent.dataSourceSettings;
            this.chartSettings = chartSettings;
            var isDataAvail = parent.dataType === 'olap' ?
                (parent.dataSourceSettings.url !== '' && !parent.olapEngineModule.isEmptyData &&
                    parent.olapEngineModule.tupColumnInfo.length > 0 && parent.olapEngineModule.tupRowInfo.length > 0 &&
                    (!ej2_base_1.isNullOrUndefined(parent.olapEngineModule.colMeasurePos) || !ej2_base_1.isNullOrUndefined(parent.olapEngineModule.rowMeasurePos)))
                : this.parent.dataSourceSettings.mode === 'Server' ? (!ej2_base_1.isNullOrUndefined(parent.dataSourceSettings.url) &&
                    parent.dataSourceSettings.url !== '' && parent.dataSourceSettings.values.length > 0 && !parent.engineModule.isEmptyData) :
                    (parent.dataSourceSettings.values.length > 0 && parent.dataSourceSettings.dataSource &&
                        (parent.dataSourceSettings.dataSource.length > 0 ||
                            (parent.dataSourceSettings.dataSource instanceof ej2_data_1.DataManager)) && !parent.engineModule.isEmptyData);
            if (isDataAvail) {
                if (!this.parent.chart && (this.parent.element.querySelector('.e-chart') || this.parent.element.querySelector('.e-accumulationchart'))) {
                    ej2_base_1.remove(ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element));
                }
                if (this.chartSettings.enableMultipleAxis && this.accumulationType.indexOf(chartSettings.chartSeries.type) < 0 && this.chartSettings.chartSeries.type !== 'Pareto') {
                    this.measureList = this.dataSourceSettings.values.map(function (item) { return item.name; });
                }
                else {
                    this.measureList = [chartSettings.value === '' ? this.dataSourceSettings.values[0].name : chartSettings.value];
                }
                for (var _i = 0, _a = this.dataSourceSettings.values; _i < _a.length; _i++) {
                    var field = _a[_i];
                    var fieldName = field.name.replace(/[^A-Z0-9]+/ig, '_');
                    this.measuresNames[field.name] = fieldName;
                    this.measuresNames[fieldName] = field.name;
                    if ((this.chartSettings.chartSeries.type === 'Polar' || this.chartSettings.chartSeries.type === 'Radar')) {
                        this.measuresNames[field.caption ? field.caption : field.name] = field.name;
                    }
                }
            }
            else Iif (this.parent.chart) {
                if (this.parent.element.querySelector('.e-chart')) {
                    this.parent.chart.series = [];
                    this.parent.chart.rows = [];
                    this.parent.chart.primaryXAxis.title = '';
                    this.parent.chart.primaryYAxis.title = '';
                    this.parent.chart.primaryXAxis.multiLevelLabels = [];
                    this.parent.chart.primaryYAxis.multiLevelLabels = [];
                    if (this.parent.chart.axes.length > 0) {
                        this.parent.chart.axes[0].title = '';
                    }
                    this.parent.chart.primaryXAxis.zoomFactor = ej2_base_1.isNullOrUndefined(this.parent.chartSettings.primaryXAxis.zoomFactor)
                        ? 1 : this.parent.chartSettings.primaryXAxis.zoomFactor;
                }
                else if (this.parent.element.querySelector('.e-accumulationchart')) {
                    this.parent.chart.series[0].dataSource = [{}];
                    this.parent.chart.series[0].dataLabel = {};
                }
                this.parent.chart.refresh();
                return;
            }
            else {
                this.parent.appendChartElement();
                Eif (this.parent.enableVirtualization && this.isChartInitial) {
                    this.isChartInitial = false;
                    this.parent.onContentReady();
                }
                this.parent.notify(events.contentReady, {});
                return;
            }
            this.columnGroupObject = {};
            this.accEmptyPoint = false;
            var pivotValues = this.engineModule.pivotValues;
            this.currentMeasure = (chartSettings.enableMultipleAxis && this.accumulationType.indexOf(chartSettings.chartSeries.type) < 0 && this.chartSettings.chartSeries.type !== 'Pareto') ? this.measureList[0] :
                (((chartSettings.value === '' || this.dataSourceSettings.values.filter(function (item) {
                    return item.name === chartSettings.value;
                }).length === 0) && this.dataSourceSettings.values.length > 0) ? this.dataSourceSettings.values[0].name : chartSettings.value);
            var totColIndex = this.getColumnTotalIndex(pivotValues);
            var rKeys = Object.keys(pivotValues);
            var prevLevel;
            var firstLevelUName;
            var levelCollection = {};
            var prevCell;
            var integratedLevel = 0;
            var indexCount = -0.5;
            this.headerColl = {};
            this.maxLevel = 0;
            var levelPos = {};
            var lastHierarchy = '';
            var lastDimension = '';
            var memberCell;
            var drillDimension = '';
            this.chartSeriesInfo = {};
            this.selectedLegend = 0;
            var isDrill = false;
            var measureNames = {};
            var isValidHeader = false;
            var delimiter = this.parent.dataSourceSettings.valueSortSettings.headerDelimiter;
            for (var _b = 0, _c = this.dataSourceSettings.values; _b < _c.length; _b++) {
                var field = _c[_b];
                var fieldName = field.name;
                measureNames[fieldName] = field.caption ? field.caption : fieldName;
                measureNames[field.caption ? field.caption : fieldName] = fieldName;
            }
            if (this.parent.dataType === 'olap') {
                var fieldPosition = [];
                levelPos = this.groupHierarchyWithLevels(pivotValues, fieldPosition);
                lastHierarchy = fieldPosition[fieldPosition.length - 1];
                lastDimension = (this.measurePos === (fieldPosition.length - 1) && fieldPosition.length > 1) ?
                    fieldPosition[fieldPosition.length - 2] : lastHierarchy;
                drillDimension = lastDimension;
            }
            for (var _d = 0, rKeys_1 = rKeys; _d < rKeys_1.length; _d++) {
                var rKey = rKeys_1[_d];
                var rowIndex = Number(rKey);
                Eif (!ej2_base_1.isNullOrUndefined(pivotValues[rowIndex])) {
                    var header = pivotValues[rowIndex][0];
                    var valueSort = header && header.valueSort && !ej2_base_1.isNullOrUndefined(header.valueSort.levelName) ?
                        header.valueSort.levelName.toString().split(delimiter) : undefined;
                    isValidHeader = false;
                    if (valueSort && valueSort[0] !== 'Grand Total') {
                        if ((chartSettings.enableMultipleAxis && this.accumulationType.indexOf(chartSettings.chartSeries.type) < 0 && this.chartSettings.chartSeries.type !== 'Pareto') ||
                            valueSort.indexOf(measureNames[this.currentMeasure]) > -1) {
                            isValidHeader = true;
                        }
                        if (!isValidHeader) {
                            for (var _e = 0, valueSort_1 = valueSort; _e < valueSort_1.length; _e++) {
                                var levelName = valueSort_1[_e];
                                if (measureNames[levelName]) {
                                    isValidHeader = true;
                                    break;
                                }
                            }
                            isValidHeader = isValidHeader ? false : true;
                        }
                    }
                    if (header && header.axis === 'row' && (this.dataSourceSettings.rows.length === 0 ? true :
                        (header.type !== 'grand sum' && isValidHeader))) {
                        var firstRowCell = pivotValues[rowIndex][0];
                        Iif (firstRowCell.isSum) {
                            continue;
                        }
                        var tupInfo = this.parent.dataType === 'olap' ?
                            this.engineModule.tupRowInfo[firstRowCell.ordinal] : undefined;
                        var fieldPos = -1;
                        var currrentLevel = firstRowCell.level;
                        if (this.parent.dataType === 'olap') {
                            isDrill = firstRowCell.hierarchy === '[Measures]' ? isDrill : this.isAttributeDrill(firstRowCell.hierarchy, tupInfo.drillInfo);
                            drillDimension = drillDimension === lastDimension ? lastDimension : (firstRowCell.hierarchy === '[Measures]' || firstRowCell.isNamedSet || (this.engineModule.fieldList[firstRowCell.hierarchy] && !this.engineModule.fieldList[firstRowCell.hierarchy].hasAllMember)) ? lastDimension : drillDimension;
                            fieldPos = tupInfo.drillInfo.length - 1;
                            Eif (firstRowCell.memberType !== 3 && (tupInfo.measureName ?
                                tupInfo.measureName === this.dataSourceSettings.values[0].name : true)) {
                                firstLevelUName = firstLevelUName === undefined ? firstRowCell.levelUniqueName : firstLevelUName;
                                integratedLevel = firstLevelUName === firstRowCell.levelUniqueName ? 0 : integratedLevel;
                                levelCollection = integratedLevel === 0 ? {} : levelCollection;
                                integratedLevel = (prevCell && firstLevelUName !== firstRowCell.levelUniqueName) ?
                                    (prevCell.hierarchy === firstRowCell.hierarchy ?
                                        (integratedLevel + (firstRowCell.level - prevCell.level)) :
                                        (ej2_base_1.isNullOrUndefined(levelCollection[firstRowCell.levelUniqueName]) ?
                                            (levelPos[firstRowCell.hierarchy].start) :
                                            levelCollection[firstRowCell.levelUniqueName])) : integratedLevel;
                                levelCollection[firstRowCell.levelUniqueName] = integratedLevel;
                                currrentLevel = integratedLevel;
                                indexCount += (prevCell && drillDimension === prevCell.hierarchy && !(prevCell.isDrilled && prevCell.hasChild))
                                    ? 1 : 0;
                                drillDimension = isDrill ? firstRowCell.hierarchy : lastDimension;
                                prevLevel = integratedLevel;
                                prevCell = firstRowCell;
                            }
                        }
                        else if (firstRowCell.type !== 'value') {
                            if (!(prevLevel === undefined || prevLevel < currrentLevel)) {
                                indexCount++;
                            }
                            prevLevel = currrentLevel;
                        }
                        this.maxLevel = currrentLevel > this.maxLevel ? currrentLevel : this.maxLevel;
                        var name_1 = this.parent.dataType === 'olap' ? firstRowCell.formattedText :
                            (firstRowCell.actualText ? firstRowCell.actualText.toString() : firstRowCell.formattedText.toString());
                        var values = this.engineModule.fieldList[this.currentMeasure];
                        var text = this.parent.dataSourceSettings.rows.length === 0 ? this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(values.aggregateType) + ' ' +
                            this.parent.localeObj.getConstant('of') + ' ' + (!ej2_base_1.isNullOrUndefined(values.caption) ? values.caption : values.name) : firstRowCell.formattedText ? firstRowCell.formattedText.toString() : name_1;
                        var caption = (firstRowCell.hasChild && !firstRowCell.isNamedSet) ?
                            ((firstRowCell.isDrilled ? ' - ' : ' + ') + text) : text;
                        var levelName = tupInfo ? tupInfo.uNameCollection : firstRowCell.valueSort.levelName.toString();
                        var cellInfo = {
                            name: name_1,
                            text: caption,
                            hasChild: firstRowCell.hasChild,
                            isDrilled: firstRowCell.isDrilled,
                            levelName: levelName,
                            level: currrentLevel,
                            fieldName: firstRowCell.valueSort.axis ? firstRowCell.valueSort.axis.toString() : '',
                            rowIndex: rowIndex,
                            colIndex: 0,
                            cell: firstRowCell
                        };
                        if (this.parent.dataType === 'olap' ? firstRowCell.memberType !== 3 : firstRowCell.type !== 'value') {
                            if (this.headerColl[indexCount]) {
                                this.headerColl[indexCount][currrentLevel] = cellInfo;
                            }
                            else {
                                this.headerColl[indexCount] = {};
                                this.headerColl[indexCount][currrentLevel] = cellInfo;
                            }
                        }
                        var rows = pivotValues[rowIndex];
                        var cKeys = Object.keys(rows);
                        var prevMemberCell = void 0;
                        if (this.parent.dataType === 'olap') {
                            memberCell = firstRowCell.memberType !== 3 ? firstRowCell : memberCell;
                        }
                        else {
                            memberCell = firstRowCell.type !== 'value' ? firstRowCell : memberCell;
                            if (firstRowCell.type !== 'value') {
                                memberCell = firstRowCell;
                            }
                            else {
                                var valueSort_2 = firstRowCell && firstRowCell.valueSort && firstRowCell.valueSort.levelName &&
                                    firstRowCell.valueSort.levelName.toString().split(delimiter);
                                var levelName_1 = void 0;
                                Eif (valueSort_2 && valueSort_2.length > 0) {
                                    valueSort_2.splice(valueSort_2.length - 1, 1);
                                    levelName_1 = valueSort_2.join(delimiter);
                                }
                                Eif ((this.parent.dataSourceSettings.valueIndex <= 0 || this.engineModule.valueAxis &&
                                    this.dataSourceSettings.rows.length === this.engineModule.measureIndex) ||
                                    ej2_base_1.isNullOrUndefined(memberCell.valueSort) || (levelName_1 === memberCell.valueSort.levelName)) {
                                    memberCell = memberCell;
                                }
                                else {
                                    var prevIndex = rowIndex;
                                    while (prevIndex > -1) {
                                        if (pivotValues[prevIndex] && pivotValues[prevIndex][0] &&
                                            pivotValues[prevIndex][0].valueSort &&
                                            pivotValues[prevIndex][0].valueSort.levelName === levelName_1) {
                                            memberCell = pivotValues[prevIndex][0];
                                            prevIndex = 0;
                                        }
                                        prevIndex--;
                                    }
                                }
                            }
                        }
                        for (var _f = 0, cKeys_1 = cKeys; _f < cKeys_1.length; _f++) {
                            var cKey = cKeys_1[_f];
                            var cellIndex = Number(cKey);
                            var cell = pivotValues[rowIndex][cellIndex];
                            var measureAllow = ej2_base_1.isNullOrUndefined(cell.rowHeaders) ? this.dataSourceSettings.rows.length === 0 : true;
                            var actualText = (this.parent.dataType === 'olap' && tupInfo && tupInfo.measureName) ?
                                tupInfo.measureName : cell.actualText;
                            if (!(this.parent.dataType === 'olap' && cell.isGrandSum) && !totColIndex[cell.colIndex] && cell.axis === 'value' && firstRowCell.type !== 'header' &&
                                actualText !== '' && ((chartSettings.enableMultipleAxis && this.accumulationType.indexOf(chartSettings.chartSeries.type) < 0 && this.chartSettings.chartSeries.type !== 'Pareto') ? true : actualText === this.currentMeasure)) {
                                if (ej2_base_1.isNullOrUndefined(firstRowCell.members)) {
                                    firstRowCell.members = [];
                                }
                                if (this.parent.dataType === 'olap' ? ((lastHierarchy === firstRowCell.hierarchy || isDrill) ?
                                    ((firstRowCell.memberType === 3 && prevMemberCell) ?
                                        (fieldPos === this.measurePos ? (prevMemberCell.isDrilled && prevMemberCell.hasChild) : true) :
                                        (firstRowCell.isDrilled && firstRowCell.hasChild)) : true)
                                    : (((firstRowCell.type === 'value' && prevMemberCell) ?
                                        (!ej2_base_1.isNullOrUndefined(prevMemberCell.members) && prevMemberCell.hasChild &&
                                            prevMemberCell.isDrilled) : firstRowCell.hasChild && firstRowCell.isDrilled) ||
                                        !measureAllow)) {
                                    break;
                                }
                                Iif (this.parent.dataType === 'olap' && cell.isSum === true && this.parent.dataSourceSettings.valueAxis === 'row') {
                                    continue;
                                }
                                var colHeaders = '';
                                if (this.parent.dataType === 'olap') {
                                    colHeaders = cell.columnHeaders.toString().split(/~~|::/).join(' - ');
                                }
                                else {
                                    var values_1 = cell.columnHeaders.toString().split(delimiter);
                                    colHeaders = util_1.PivotUtil.formatChartHeaders(values_1, this, true);
                                }
                                var rowHeaders = '';
                                if (this.parent.dataType === 'olap') {
                                    rowHeaders = cell.rowHeaders.toString().split(/~~|::/).join(' - ');
                                }
                                else {
                                    var values_2 = cell.rowHeaders.toString().split(delimiter);
                                    rowHeaders = util_1.PivotUtil.formatChartHeaders(values_2, this, false);
                                }
                                var columnSeries = colHeaders + ' | ' + actualText;
                                this.chartSeriesInfo[colHeaders] = { uniqueName: colHeaders, caption: cell.hierarchyName && cell.hierarchyName.toString().split(delimiter).join(' - '), colorIndex: [] };
                                this.chartSeriesInfo[this.chartSeriesInfo[colHeaders].caption] =
                                    this.chartSeriesInfo[colHeaders];
                                var yValue = (this.parent.dataType === 'pivot' ? (this.engineModule.aggregatedValueMatrix[rowIndex] &&
                                    !ej2_base_1.isNullOrUndefined(this.engineModule.aggregatedValueMatrix[rowIndex][cellIndex])) ?
                                    Number(this.engineModule.aggregatedValueMatrix[rowIndex][cellIndex]) :
                                    (!ej2_base_1.isNullOrUndefined(cell.value) ? Number(cell.value) : cell.value) : (!ej2_base_1.isNullOrUndefined(cell.value)
                                    ? Number(cell.value) : cell.value));
                                yValue = yValue === Infinity ? null : yValue;
                                if (yValue === 0) {
                                    this.accEmptyPoint = true;
                                }
                                if (this.columnGroupObject[columnSeries]) {
                                    this.columnGroupObject[columnSeries].push({
                                        x: this.dataSourceSettings.rows.length === 0 ? firstRowCell.formattedText : rowHeaders,
                                        y: yValue,
                                        rIndex: rowIndex,
                                        cIndex: cellIndex
                                    });
                                }
                                else {
                                    this.columnGroupObject[columnSeries] = [{
                                            x: this.dataSourceSettings.rows.length === 0 ? firstRowCell.formattedText : rowHeaders,
                                            y: yValue,
                                            rIndex: rowIndex,
                                            cIndex: cellIndex
                                        }];
                                }
                            }
                            prevMemberCell = memberCell;
                        }
                    }
                }
            }
            this.refreshChart();
        };
        PivotChart.prototype.refreshChart = function () {
            this.chartSeries = [];
            var prevColorIndex = 0;
            var chartSeriesInfo = {};
            var columnKeys = Object.keys(this.columnGroupObject);
            this.persistSettings = JSON.parse(this.parent.getChartSettings()).chartSettings;
            var seriesColors = this.persistSettings.palettes && this.persistSettings.palettes.length > 0
                ? this.persistSettings.palettes : ej2_charts_10.getSeriesColor(this.chartSettings.theme);
            var delimiter = this.parent.chartSettings.columnDelimiter ? this.parent.chartSettings.columnDelimiter : '-';
            var columnHeader = (this.parent.chartSettings.columnHeader && this.parent.chartSettings.columnHeader !== '') ?
                this.parent.chartSettings.columnHeader.split(delimiter).join(' - ') : '';
            var chartType = this.chartSettings.chartSeries ? this.chartSettings.chartSeries.type : undefined;
            var fieldWithCaption = {};
            for (var i = 0; i < this.parent.dataSourceSettings.values.length; i++) {
                fieldWithCaption[this.parent.dataSourceSettings.values[i].name] =
                    !ej2_base_1.isNullOrUndefined(this.parent.dataSourceSettings.values[i].caption) ?
                        this.parent.dataSourceSettings.values[i].caption : undefined;
            }
            if (this.accumulationType.indexOf(chartType) > -1 && columnKeys.length > 0) {
                this.currentColumn = (columnKeys.indexOf(columnHeader + ' | ' + this.currentMeasure) > -1 && columnHeader !== undefined) ? columnHeader + ' | ' + this.currentMeasure : columnKeys[0];
                var currentSeries = {};
                currentSeries = this.persistSettings.chartSeries ? this.frameChartSeries(this.persistSettings.chartSeries) : currentSeries;
                Iif ((ej2_base_1.isNullOrUndefined(currentSeries.palettes) || currentSeries.palettes.length === 0) &&
                    !ej2_base_1.isNullOrUndefined(this.persistSettings.palettes) && this.persistSettings.palettes.length > 0) {
                    currentSeries.palettes = this.persistSettings.palettes;
                }
                currentSeries.dataSource = this.columnGroupObject[this.currentColumn];
                currentSeries.xName = 'x';
                currentSeries.yName = 'y';
                if (this.persistSettings.chartSeries && this.persistSettings.chartSeries.dataLabel) {
                    currentSeries.dataLabel = this.persistSettings.chartSeries.dataLabel;
                    currentSeries.dataLabel.name = 'x';
                }
                else {
                    currentSeries.dataLabel = { visible: true, position: 'Outside', name: 'x' };
                    this.parent.setProperties({ chartSettings: { chartSeries: { dataLabel: { visible: true, position: 'Outside' } } } }, true);
                }
                Iif (this.accEmptyPoint && currentSeries.emptyPointSettings) {
                    currentSeries.emptyPointSettings.mode = 'Zero';
                }
                else if (this.accEmptyPoint) {
                    currentSeries.emptyPointSettings = { mode: 'Zero' };
                }
                currentSeries.name = this.currentColumn;
                Iif (chartType === 'Doughnut') {
                    currentSeries.type = 'Pie';
                    currentSeries.innerRadius = this.chartSettings.chartSeries.innerRadius ? this.chartSettings.chartSeries.innerRadius : '40%';
                }
                else Eif (chartType === 'Pie') {
                    currentSeries.innerRadius = this.chartSettings.chartSeries.innerRadius ? this.chartSettings.chartSeries.innerRadius : '0';
                }
                this.chartSeries = this.chartSeries.concat(currentSeries);
            }
            else {
                for (var _i = 0, columnKeys_1 = columnKeys; _i < columnKeys_1.length; _i++) {
                    var key = columnKeys_1[_i];
                    var currentSeries = {};
                    currentSeries = this.persistSettings.chartSeries ? this.frameChartSeries(this.persistSettings.chartSeries) : currentSeries;
                    Iif (!ej2_base_1.isNullOrUndefined(currentSeries.palettes) &&
                        currentSeries.palettes.length > 0 && (ej2_base_1.isNullOrUndefined(this.persistSettings.palettes) ||
                        this.persistSettings.palettes.length === 0)) {
                        this.chartSettings.palettes = currentSeries.palettes;
                    }
                    for (var i = 0; i < this.columnGroupObject[key].length; i++) {
                        var values = this.engineModule.fieldList[this.currentMeasure];
                        this.columnGroupObject[key][i].x = (this.parent.dataSourceSettings.rows.length === 0 && !this.chartSettings.showMultiLevelLabels) ? this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(values.aggregateType) + ' ' +
                            this.parent.localeObj.getConstant('of') + ' ' + (!ej2_base_1.isNullOrUndefined(values.caption) ? values.caption : values.name) : this.columnGroupObject[key][i].x === '' ? this.parent.localeObj.getConstant('blank') : this.columnGroupObject[key][i].x;
                    }
                    currentSeries.dataSource = this.columnGroupObject[key];
                    currentSeries.xName = 'x';
                    currentSeries.yName = 'y';
                    currentSeries.visible = true;
                    var multiAxisKey = void 0;
                    var fieldName = void 0;
                    var currentSeriesName = void 0;
                    for (var i = 0, j = key.split(' | '); i < j.length; i++) {
                        if (this.measuresNames && this.measuresNames[j[i]]) {
                            fieldName = j[i];
                            currentSeriesName = key.split((' | ' + fieldName))[0];
                        }
                    }
                    if (this.chartSettings.enableMultipleAxis) {
                        var fieldCaptionName = fieldName;
                        fieldCaptionName = !ej2_base_1.isNullOrUndefined(fieldWithCaption[fieldCaptionName]) ?
                            fieldWithCaption[fieldCaptionName] : fieldCaptionName;
                        multiAxisKey = currentSeriesName + ' | ' + fieldCaptionName;
                    }
                    currentSeries.name = this.chartSettings.enableMultipleAxis ? multiAxisKey : currentSeriesName;
                    if (this.chartSettings.showPointColorByMembers && this.chartSettings.enableMultipleAxis) {
                        currentSeries.name = currentSeriesName;
                        var seriesName = this.chartSeriesInfo[currentSeries.name].caption;
                        currentSeries.name = seriesName !== undefined && seriesName !== null ? seriesName : currentSeries.name;
                        if (!chartSeriesInfo[currentSeries.name]) {
                            prevColorIndex = seriesColors[prevColorIndex] ? prevColorIndex : 0;
                            chartSeriesInfo[currentSeries.name] = { name: currentSeries.name, color: seriesColors[prevColorIndex] };
                            currentSeries.fill = seriesColors[prevColorIndex++];
                            this.chartSeriesInfo[currentSeries.name].colorIndex.push(this.selectedLegend++);
                        }
                        else {
                            currentSeries.fill = chartSeriesInfo[currentSeries.name].color;
                            this.chartSeriesInfo[currentSeries.name].colorIndex.push(this.selectedLegend++);
                            currentSeries.name = undefined;
                        }
                    }
                    if (['Radar', 'Polar'].indexOf(chartType) < 0) {
                        var measure = fieldName;
                        currentSeries.tooltipMappingName = this.measuresNames[measure];
                        currentSeries.yAxisName = (this.chartSettings.enableMultipleAxis && this.chartSettings.multipleAxisMode === 'Combined') ?
                            this.measureList.join('_') : this.measuresNames[measure] ? this.measuresNames[measure] : measure;
                    }
                    Iif (this.persistSettings.chartSeries && this.persistSettings.chartSeries.emptyPointSettings) {
                        currentSeries.emptyPointSettings = this.persistSettings.chartSeries.emptyPointSettings;
                    }
                    Eif (!currentSeries.emptyPointSettings) {
                        currentSeries.emptyPointSettings = { mode: 'Zero' };
                    }
                    this.chartSeries = this.chartSeries.concat(currentSeries);
                }
            }
            var seriesEvent = { series: this.chartSeries, cancel: false };
            var pivotChart = this;
            this.parent.trigger(events.chartSeriesCreated, seriesEvent, function (observedArgs) {
                if (!observedArgs.cancel) {
                    pivotChart.bindChart();
                }
                else {
                    Eif (pivotChart.element) {
                        ej2_base_1.remove(pivotChart.element);
                    }
                    pivotChart.parent.notify(events.contentReady, {});
                }
            });
        };
        PivotChart.prototype.frameObjectWithKeys = function (series) {
            var keys = Object.keys(series);
            var keyPos = 0;
            var framedSeries = {};
            while (keyPos < keys.length) {
                framedSeries[keys[keyPos]] = series[keys[keyPos]];
                keyPos++;
            }
            return framedSeries;
        };
        PivotChart.prototype.frameChartSeries = function (series) {
            var keys = Object.keys(series);
            var keyPos = 0;
            var framedSeries = {};
            while (keyPos < keys.length) {
                Iif ((this.accumulationType.indexOf(this.parent.chartSettings.chartSeries.type) > -1 && ['fill', 'dashArray', 'width', 'segmentAxis',
                    'drawType', 'isClosed', 'segments', 'stackingGroup', 'marker', 'errorBar', 'trendlines', 'minRadius',
                    'splineType', 'maxRadius', 'cardinalSplineTension', 'columnWidth', 'columnSpacing', 'cornerRadius'].indexOf(keys[keyPos]) > -1) ||
                    (this.accumulationType.indexOf(this.parent.chartSettings.chartSeries.type) < 0 && ['endAngle', 'explode', 'explodeAll', 'explodeIndex',
                        'explodeOffset', 'gapRatio', 'groupMode', 'groupTo', 'neckHeight', 'neckWidth', 'pyramidMode', 'startAngle',
                        'dataLabel', 'innerRadius'].indexOf(keys[keyPos]) > -1)) {
                    keyPos++;
                    continue;
                }
                framedSeries[keys[keyPos]] = series[keys[keyPos]];
                keyPos++;
            }
            return framedSeries;
        };
        PivotChart.prototype.bindChart = function () {
            this.parent.showWaitingPopup();
            var currentXAxis = this.configXAxis();
            var currentTooltipSettings = this.configTooltipSettings();
            var currentLegendSettings = this.configLegendSettings();
            var currentZoomSettings = this.configZoomSettings();
            var axesWithRows = this.frameAxesWithRows();
            var type = this.chartSettings.chartSeries.type;
            if (this.parent.displayOption.view === 'Both') {
                this.element = this.parent.displayOption.primary === 'Chart' ?
                    (this.parent.element.insertBefore((!this.element ?
                        (ej2_base_1.createElement('div', {
                            className: cls.PIVOTCHART, id: this.parent.element.id + '_chart'
                        }))
                        : this.element), this.parent.element.querySelector('.' + cls.GRID_CLASS))) :
                    (this.parent.element.appendChild(!this.element ? (ej2_base_1.createElement('div', {
                        className: cls.PIVOTCHART, id: this.parent.element.id + '_chart'
                    })) : this.element));
            }
            else if (!this.element) {
                this.element = this.parent.element.appendChild(ej2_base_1.createElement('div', {
                    className: cls.PIVOTCHART, id: this.parent.element.id + '_chart'
                }));
            }
            if (!this.chartElement && this.parent.chartSettings.enableScrollOnMultiAxis && this.parent.chartSettings.enableMultipleAxis && this.chartSettings.chartSeries.type !== 'Pareto') {
                this.parent.element.querySelector('.' + cls.PIVOTCHART).innerHTML = '';
                this.chartElement = this.parent.element.querySelector('.' + cls.PIVOTCHART).appendChild(ej2_base_1.createElement('div', {
                    className: cls.PIVOTCHART_INNER, id: this.parent.element.id + '_chartInner'
                }));
            }
            if (this.parent.element.querySelector('.' + cls.PIVOTCHART_INNER)) {
                this.parent.element.querySelector('.' + cls.PIVOTCHART_INNER).innerHTML = '';
            }
            if (this.parent.showGroupingBar) {
                this.element.style.minWidth = '400px !important';
            }
            else {
                this.element.style.minWidth = '310px !important';
            }
            var width = this.parent.width.toString();
            if (this.parent.showToolbar && this.parent.grid) {
                width = this.parent.getGridWidthAsNumber().toString();
            }
            var height = this.getChartHeight();
            if (this.parent.chartSettings.enableScrollOnMultiAxis && this.parent.chartSettings.enableMultipleAxis &&
                this.accumulationType.indexOf(type) < 0 && this.chartSettings.chartSeries.type !== 'Pareto') {
                this.parent.element.querySelector('.' + cls.PIVOTCHART).style.height =
                    (height === 'auto' ? this.getChartAutoHeight() : height) + 'px';
                this.parent.element.querySelector('.' + cls.PIVOTCHART).style.width = width + 'px';
                Eif (this.parent.chartSettings.chartSeries.type !== 'Polar' && this.parent.chartSettings.chartSeries.type !== 'Radar') {
                    this.parent.element.querySelector('.' + cls.PIVOTCHART).style.overflow = 'auto';
                    this.parent.element.querySelector('.' + cls.PIVOTCHART).style.overflowX = 'hidden';
                }
            }
            Iif (this.parent.chart && ((this.parent.chart.getModuleName() === 'accumulationchart' &&
                this.accumulationType.indexOf(type) < 0) || (this.parent.chart.getModuleName() === 'chart' &&
                this.accumulationType.indexOf(type) > -1 && this.chartSettings.chartSeries.type !== 'Pareto'))) {
                this.parent.chart.destroy();
                if (ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element)) {
                    ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element).innerHTML = '';
                    ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element).appendChild(ej2_base_1.createElement('div', {
                        className: cls.PIVOTCHART_INNER, id: this.parent.element.id + '_chartInner'
                    }));
                }
            }
            if (!(this.parent.chart && this.parent.chart.element && this.parent.element.querySelector('.e-chart') || this.parent.element.querySelector('.e-accumulationchart')) ||
                (this.parent.toolbarModule && this.parent.toolbarModule.isMultiAxisChange)) {
                Iif (this.parent.toolbarModule && this.parent.toolbarModule.isMultiAxisChange && this.parent.chart) {
                    if (!this.parent.chart.isDestroyed) {
                        this.parent.chart.destroy();
                    }
                    this.parent.chart = undefined;
                    ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element).innerHTML = '';
                    ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element).appendChild(ej2_base_1.createElement('div', {
                        className: cls.PIVOTCHART_INNER, id: this.parent.element.id + '_chartInner'
                    }));
                    this.parent.toolbarModule.isMultiAxisChange = false;
                }
                ej2_charts_1.Chart.Inject(ej2_charts_1.ColumnSeries, ej2_charts_5.StackingColumnSeries, ej2_charts_5.RangeColumnSeries, ej2_charts_5.BarSeries, ej2_charts_5.StackingBarSeries, ej2_charts_5.ScatterSeries, ej2_charts_9.BubbleSeries, ej2_charts_1.LineSeries, ej2_charts_4.StepLineSeries, ej2_charts_4.SplineSeries, ej2_charts_3.SplineAreaSeries, ej2_charts_3.MultiColoredLineSeries, ej2_charts_7.PolarSeries, ej2_charts_6.RadarSeries, ej2_charts_1.AreaSeries, ej2_charts_3.RangeAreaSeries, ej2_charts_3.StackingAreaSeries, ej2_charts_3.StepAreaSeries, ej2_charts_1.StackingLineSeries, ej2_charts_4.MultiColoredAreaSeries, ej2_charts_8.ParetoSeries, ej2_charts_1.Legend, ej2_charts_1.Tooltip, ej2_charts_1.Category, ej2_charts_8.MultiLevelLabel, ej2_charts_7.ScrollBar, ej2_charts_7.Zoom, ej2_charts_8.Export, ej2_charts_8.Crosshair, ej2_charts_1.Selection, ej2_charts_1.StripLine, ej2_charts_1.DataLabel);
                ej2_charts_2.AccumulationChart.Inject(ej2_charts_2.PieSeries, ej2_charts_2.FunnelSeries, ej2_charts_2.PyramidSeries, ej2_charts_10.AccumulationDataLabel, ej2_charts_4.AccumulationLegend, ej2_charts_4.AccumulationTooltip, ej2_charts_8.Export);
                if (this.accumulationType.indexOf(type) > -1) {
                    this.parent.chart = new ej2_charts_2.AccumulationChart({
                        series: this.chartSeries.length > 0 ? this.chartSeries : [{}],
                        legendSettings: currentLegendSettings,
                        tooltip: currentTooltipSettings,
                        width: width,
                        height: height.toString(),
                        title: this.chartSettings.title,
                        enableSmartLabels: this.chartSettings.enableSmartLabels,
                        center: this.chartSettings.pieCenter,
                        enableBorderOnMouseMove: this.chartSettings.enableBorderOnMouseMove,
                        highlightMode: this.chartSettings.highlightMode,
                        highlightPattern: this.chartSettings.highlightPattern,
                        titleStyle: this.chartSettings.titleStyle,
                        subTitle: this.chartSettings.subTitle,
                        subTitleStyle: this.chartSettings.subTitleStyle,
                        margin: this.chartSettings.margin,
                        border: this.chartSettings.border,
                        background: this.chartSettings.background,
                        theme: this.chartSettings.theme,
                        selectionMode: this.chartSettings.accumulationSelectionMode,
                        isMultiSelect: this.chartSettings.isMultiSelect,
                        enableExport: this.chartSettings.enableExport,
                        selectedDataIndexes: this.chartSettings.selectedDataIndexes,
                        enableAnimation: this.chartSettings.enableAnimation,
                        useGroupingSeparator: this.chartSettings.useGroupingSeparator,
                        locale: this.parent.locale,
                        enableRtl: this.parent.enableRtl,
                        beforePrint: this.beforePrint.bind(this),
                        animationComplete: this.animationComplete.bind(this),
                        legendRender: this.legendRender.bind(this),
                        textRender: this.textRender.bind(this),
                        pointRender: this.pointRender.bind(this),
                        seriesRender: this.seriesRender.bind(this),
                        chartMouseMove: this.chartMouseMove.bind(this),
                        chartMouseClick: this.chartMouseClick.bind(this),
                        pointMove: this.pointMove.bind(this),
                        pointClick: this.pointClick.bind(this),
                        chartMouseLeave: this.chartMouseLeave.bind(this),
                        chartMouseDown: this.chartMouseDown.bind(this),
                        chartMouseUp: this.chartMouseUp.bind(this),
                        tooltipRender: this.tooltipRender.bind(this),
                        loaded: this.loaded.bind(this),
                        load: this.load.bind(this),
                        resized: this.resized.bind(this)
                    });
                }
                else {
                    this.parent.chart = new ej2_charts_1.Chart({
                        series: this.chartSeries.length > 0 ? this.chartSeries : [{}],
                        legendSettings: currentLegendSettings,
                        tooltip: currentTooltipSettings,
                        zoomSettings: currentZoomSettings,
                        axes: (type === 'Polar' || type === 'Radar') ? [] : axesWithRows.axes,
                        rows: (type === 'Polar' || type === 'Radar') ? [{}] :
                            (type === 'Bar' || type === 'StackingBar' || type === 'StackingBar100' || type === 'Pareto' &&
                                this.chartSettings.enableMultipleAxis) ? [{ height: '100%' }] : axesWithRows.rows,
                        columns: (type === 'Polar' || type === 'Radar') ? [{}] :
                            (type === 'Bar' || type === 'StackingBar' || type === 'StackingBar100' &&
                                this.chartSettings.enableMultipleAxis) ? axesWithRows.columns : [{ width: '100%' }],
                        primaryYAxis: (type === 'Polar' || type === 'Radar') ? axesWithRows.axes[0] : { visible: false },
                        primaryXAxis: currentXAxis,
                        width: width,
                        height: (this.parent.chartSettings.chartSeries.type !== 'Polar' &&
                            this.parent.chartSettings.chartSeries.type !== 'Radar' && this.parent.chartSettings.enableScrollOnMultiAxis &&
                            this.parent.chartSettings.enableMultipleAxis && this.parent.chartSettings.chartSeries.type !== 'Pareto' && this.parent.dataSourceSettings.values.length > 0) ?
                            Number(height) > (this.parent.dataSourceSettings.values.length * 235) + 100 ? isNaN(Number(height)) ?
                                height.toString() : (Number(height) - 5).toString() :
                                (!isNaN(Number(height)) || this.parent.dataSourceSettings.values.length > 1) ?
                                    ((this.parent.dataSourceSettings.values.length * 235) + 100).toString() :
                                    height.toString() : height.toString(),
                        title: this.chartSettings.title,
                        titleStyle: this.chartSettings.titleStyle,
                        subTitle: this.chartSettings.subTitle,
                        subTitleStyle: this.chartSettings.subTitleStyle,
                        margin: this.chartSettings.margin,
                        border: this.chartSettings.border,
                        background: this.chartSettings.background,
                        chartArea: !ej2_base_1.isNullOrUndefined(this.persistSettings.chartArea) ? this.persistSettings.chartArea :
                            this.chartSettings.chartArea,
                        palettes: this.chartSettings.palettes,
                        theme: this.chartSettings.theme,
                        crosshair: this.chartSettings.crosshair,
                        selectionMode: this.chartSettings.selectionMode,
                        isMultiSelect: this.chartSettings.isMultiSelect,
                        enableExport: this.chartSettings.enableExport,
                        selectedDataIndexes: this.chartSettings.selectedDataIndexes,
                        isTransposed: this.chartSettings.isTransposed,
                        enableAnimation: this.chartSettings.enableAnimation,
                        enableCanvas: this.chartSettings.enableCanvas,
                        useGroupingSeparator: this.chartSettings.useGroupingSeparator,
                        description: this.chartSettings.description,
                        tabIndex: this.chartSettings.tabIndex,
                        locale: this.parent.locale,
                        enableRtl: this.parent.enableRtl,
                        enableSideBySidePlacement: this.chartSettings.enableSideBySidePlacement,
                        beforePrint: this.beforePrint.bind(this),
                        animationComplete: this.animationComplete.bind(this),
                        legendRender: this.legendRender.bind(this),
                        textRender: this.textRender.bind(this),
                        pointRender: this.pointRender.bind(this),
                        seriesRender: this.seriesRender.bind(this),
                        chartMouseMove: this.chartMouseMove.bind(this),
                        chartMouseClick: this.chartMouseClick.bind(this),
                        pointMove: this.pointMove.bind(this),
                        pointClick: this.pointClick.bind(this),
                        chartMouseLeave: this.chartMouseLeave.bind(this),
                        chartMouseDown: this.chartMouseDown.bind(this),
                        chartMouseUp: this.chartMouseUp.bind(this),
                        dragComplete: this.dragComplete.bind(this),
                        zoomComplete: this.zoomComplete.bind(this),
                        scrollStart: this.scrollStart.bind(this),
                        scrollEnd: this.scrollEnd.bind(this),
                        scrollChanged: this.scrollChanged.bind(this),
                        tooltipRender: this.tooltipRender.bind(this),
                        legendClick: this.legendClick.bind(this),
                        loaded: this.loaded.bind(this),
                        load: this.load.bind(this),
                        resized: this.resized.bind(this),
                        axisLabelRender: this.axisLabelRender.bind(this),
                        multiLevelLabelClick: this.multiLevelLabelClick.bind(this),
                        axisMultiLabelRender: this.multiLevelLabelRender.bind(this)
                    });
                }
                this.parent.chart.isStringTemplate = true;
            }
            else {
                this.parent.chart.series = this.chartSeries;
                this.parent.chart.title = this.parent.chartSettings.title;
                this.parent.chart.subTitle = this.parent.chartSettings.subTitle;
                this.parent.chart.background = this.parent.chartSettings.background;
                this.parent.chart.theme = this.parent.chartSettings.theme;
                this.parent.chart.legendSettings = currentLegendSettings;
                this.parent.chart.selectionMode = this.parent.chartSettings.selectionMode;
                this.parent.chart.enableExport = this.parent.chartSettings.enableExport;
                this.parent.chart.isMultiSelect = this.parent.chartSettings.isMultiSelect;
                this.parent.chart.enableAnimation = this.parent.chartSettings.enableAnimation;
                this.parent.chart.useGroupingSeparator = this.parent.chartSettings.useGroupingSeparator;
                this.parent.chart.highlightPattern = this.parent.chartSettings.highlightPattern;
                if (this.accumulationType.indexOf(type) > -1) {
                    this.parent.chart.enableBorderOnMouseMove = this.parent.chartSettings.enableBorderOnMouseMove;
                    this.parent.chart.highlightMode = this.parent.chartSettings.highlightMode;
                    this.parent.chart.enableSmartLabels = this.parent.chartSettings.enableSmartLabels;
                }
                else {
                    this.parent.chart.palettes = this.parent.chartSettings.palettes;
                    this.parent.chart.isTransposed = this.parent.chartSettings.isTransposed;
                    this.parent.chart.enableSideBySidePlacement = this.parent.chartSettings.enableSideBySidePlacement;
                    this.parent.chart.tabIndex = this.parent.chartSettings.tabIndex;
                    this.parent.chart.description = this.parent.chartSettings.description;
                    this.parent.chart.enableCanvas = this.parent.chartSettings.enableCanvas;
                }
                if (type === 'Polar' || type === 'Radar') {
                    this.parent.chart.primaryXAxis = currentXAxis;
                    this.parent.chart.primaryYAxis.visible = true;
                    this.parent.chart.primaryYAxis = axesWithRows.axes[0];
                    this.parent.chart.axes = [];
                    this.parent.chart.rows = [{}];
                }
                else if ((this.accumulationType.indexOf(type) < 0) && this.parent.chart.getModuleName() === 'chart') {
                    this.parent.chart.primaryYAxis.visible = false;
                    this.parent.chart.primaryXAxis = currentXAxis;
                    this.parent.chart.axes = axesWithRows.axes;
                    if (type === 'Bar' || type === 'StackingBar' || type === 'StackingBar100' &&
                        this.chartSettings.enableMultipleAxis) {
                        this.parent.chart.rows = [{ height: '100%' }];
                        this.parent.chart.columns = axesWithRows.columns;
                    }
                    else Iif (type === 'Pareto' && this.chartSettings.enableMultipleAxis) {
                        this.parent.chart.rows = [{ height: '100%' }];
                        this.parent.chart.columns = [{ width: '100%' }];
                    }
                    else {
                        this.parent.chart.rows = axesWithRows.rows;
                        this.parent.chart.columns = [{ width: '100%' }];
                    }
                }
                this.parent.chart.refresh();
                Iif ((this.accumulationType.indexOf(type) > -1) && this.parent.chart.getModuleName() === 'accumulationchart' && (this.parent.dataSourceSettings.rows.length === 0 || this.parent.dataSourceSettings.columns.length === 0)) {
                    this.parent.hideWaitingPopup();
                    if (this.parent.pivotFieldListModule) {
                        ej2_popups_1.hideSpinner(this.parent.pivotFieldListModule.fieldListSpinnerElement);
                    }
                }
            }
            if (this.parent.chartSettings.enableScrollOnMultiAxis && this.parent.chartSettings.enableMultipleAxis) {
                this.parent.chart.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_chartInner', this.parent.element));
            }
            else {
                this.parent.chart.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element));
            }
        };
        PivotChart.prototype.legendClick = function (args) {
            if (this.chartSettings.showPointColorByMembers && this.chartSettings.enableMultipleAxis) {
                var colorIndex = this.chartSeriesInfo[args.legendText].colorIndex;
                for (var i = 1; i < colorIndex.length; i++) {
                    args.chart.series[colorIndex[i]].visible = !args.chart.series[colorIndex[i]].visible;
                }
            }
            this.parent.trigger(events.chartLegendClick, args);
        };
        PivotChart.prototype.pointClick = function (args) {
            var dataSource = args.series.dataSource ? args.series.dataSource :
                this.parent.chart.series[args.seriesIndex].dataSource;
            if (((['Pie', 'Funnel', 'Doughnut', 'Pyramid', 'Radar', 'Polar'].indexOf(this.parent.chartSettings.chartSeries.type) > -1) ||
                !this.parent.chartSettings.showMultiLevelLabels) && (this.parent.dataType === 'olap' ? true :
                this.parent.dataSourceSettings.rows.length > 1)) {
                this.pivotIndex = {
                    rIndex: dataSource ? dataSource[args.pointIndex].rIndex : undefined,
                    cIndex: dataSource ? dataSource[args.pointIndex].cIndex : undefined
                };
                this.creatMenu();
                var pos = this.parent.element.getBoundingClientRect();
                var y = (this.parent.element.querySelector('.e-pivot-toolbar') ?
                    this.parent.element.querySelector('.e-pivot-toolbar').clientHeight : 0) +
                    (this.parent.element.querySelector('.e-chart-grouping-bar') ?
                        this.parent.element.querySelector('.e-chart-grouping-bar').clientHeight : 0) +
                    (window.scrollY || document.documentElement.scrollTop) + pos.top;
                this.accumulationMenu.open(y + args.y, args.x + pos.left + (window.scrollX || document.documentElement.scrollLeft));
            }
            else if ((this.parent.allowDrillThrough || this.parent.editSettings.allowEditing) && this.parent.drillThroughModule) {
                var rIndex = dataSource[args.pointIndex].rIndex;
                var cIndex = dataSource[args.pointIndex].cIndex;
                this.parent.drillThroughModule.executeDrillThrough(this.parent.pivotValues[rIndex][cIndex], rIndex, cIndex);
            }
            this.parent.trigger(events.chartPointClick, args);
        };
        PivotChart.prototype.frameAxesWithRows = function () {
            var axes = [];
            var rows = [];
            var columns = [];
            var yAxisTitles = [];
            var percentChart = this.persistSettings.chartSeries && (this.persistSettings.chartSeries.type === 'StackingColumn100' ||
                this.persistSettings.chartSeries.type === 'StackingBar100' ||
                this.persistSettings.chartSeries.type === 'StackingArea100' ||
                this.persistSettings.chartSeries.type === 'StackingLine100');
            var percentAggregateTypes = ['PercentageOfGrandTotal', 'PercentageOfColumnTotal', 'PercentageOfRowTotal',
                'PercentageOfDifferenceFrom', 'PercentageOfParentRowTotal', 'PercentageOfParentColumnTotal', 'PercentageOfParentTotal'];
            if (this.chartSettings.enableMultipleAxis) {
                var valCnt = 0;
                var divider = (100 / this.dataSourceSettings.values.length) + '%';
                for (var _i = 0, _a = this.dataSourceSettings.values; _i < _a.length; _i++) {
                    var item = _a[_i];
                    var measureField = this.engineModule.fieldList[item.name];
                    var measureAggregatedName = (this.parent.dataType === 'olap' ? '' : (this.parent.localeObj.getConstant(measureField.aggregateType) + ' ' +
                        this.parent.localeObj.getConstant('of') + ' ')) + measureField.caption;
                    yAxisTitles.push(measureAggregatedName);
                    var formatSetting = void 0;
                    for (var _b = 0, _c = this.dataSourceSettings.formatSettings; _b < _c.length; _b++) {
                        var field = _c[_b];
                        if (field.name === item.name) {
                            formatSetting = field;
                            break;
                        }
                    }
                    var format = util_1.PivotUtil.inArray(measureField.aggregateType, percentAggregateTypes) !== -1 ? 'P2' : (formatSetting ?
                        (formatSetting.format.toLowerCase().match(/n|p|c/) === null ? 'N' : formatSetting.format) :
                        this.parent.dataType === 'olap' ? this.getFormat(measureField.formatString) : 'N');
                    var resFormat = (this.chartSettings.chartSeries.type === 'Polar' || this.chartSettings.chartSeries.type === 'Radar') ? true : false;
                    var currentYAxis = {};
                    currentYAxis = this.persistSettings.primaryYAxis ? this.frameObjectWithKeys(this.persistSettings.primaryYAxis) : currentYAxis;
                    currentYAxis.labelFormat = currentYAxis.labelFormat ?
                        currentYAxis.labelFormat : (percentChart ? '' : (!resFormat ? format : 'N'));
                    currentYAxis.title = (this.chartSettings.multipleAxisMode === 'Combined') ? yAxisTitles.join(' - ') :
                        currentYAxis.title ? currentYAxis.title : measureAggregatedName;
                    currentYAxis.zoomFactor = ej2_base_1.isNullOrUndefined(this.chartSettings.primaryYAxis.zoomFactor) ? 1
                        : this.chartSettings.primaryYAxis.zoomFactor;
                    currentYAxis.edgeLabelPlacement = this.chartSettings.primaryYAxis.edgeLabelPlacement ?
                        this.chartSettings.primaryYAxis.edgeLabelPlacement : this.persistSettings.primaryYAxis.edgeLabelPlacement;
                    if (this.chartSettings.chartSeries.type === 'Bar' || this.chartSettings.chartSeries.type === 'StackingBar' ||
                        this.chartSettings.chartSeries.type === 'StackingBar100') {
                        currentYAxis.plotOffsetRight = currentYAxis.plotOffsetRight ? currentYAxis.plotOffsetRight : 30;
                    }
                    else {
                        currentYAxis.plotOffsetTop = currentYAxis.plotOffsetTop ? currentYAxis.plotOffsetTop : 30;
                    }
                    Eif (!resFormat) {
                        currentYAxis.name = (this.chartSettings.multipleAxisMode === 'Combined') ? this.measureList.join('_') :
                            this.measuresNames[item.name] ? this.measuresNames[item.name] : item.name;
                    }
                    axes = axes.concat(currentYAxis);
                    Iif (this.chartSettings.multipleAxisMode === 'Combined') {
                        axes = [axes[axes.length - 1]];
                    }
                    Eif (this.chartSettings.multipleAxisMode === 'Stacked') {
                        currentYAxis.rowIndex = valCnt;
                        currentYAxis.columnIndex = valCnt;
                        rows.push({ height: divider });
                        columns.push({ width: divider });
                    }
                    else {
                        currentYAxis.rowIndex = 0;
                        currentYAxis.columnIndex = 0;
                        rows = [{ height: '100%' }];
                        columns = [{ width: '100%' }];
                    }
                    valCnt++;
                }
            }
            else {
                var measureField = this.engineModule.fieldList[this.currentMeasure];
                var measureAggregatedName = (this.parent.dataType === 'olap' ? '' :
                    (this.parent.localeObj.getConstant(measureField.aggregateType) + ' ' +
                        this.parent.localeObj.getConstant('of') + ' ')) + measureField.caption;
                var formatSetting = void 0;
                for (var _d = 0, _e = this.dataSourceSettings.formatSettings; _d < _e.length; _d++) {
                    var item = _e[_d];
                    if (item.name === this.currentMeasure) {
                        formatSetting = item;
                        break;
                    }
                }
                var lengthofFormat = void 0;
                if (formatSetting) {
                    lengthofFormat = formatSetting.format.length;
                }
                var currentYAxis = {};
                var format = util_1.PivotUtil.inArray(measureField.aggregateType, percentAggregateTypes) !== -1 ? 'P2' : (formatSetting ?
                    (((formatSetting.format.toLowerCase().match(/n[0-10]|p[0-10]|c[0-10]/) === null) || lengthofFormat > 3) ? 'N' : formatSetting.format) :
                    this.parent.dataType === 'olap' ? this.getFormat(measureField.formatString) : 'N');
                currentYAxis = this.persistSettings.primaryYAxis ? this.frameObjectWithKeys(this.persistSettings.primaryYAxis) : currentYAxis;
                currentYAxis.zoomFactor = ej2_base_1.isNullOrUndefined(this.chartSettings.primaryYAxis.zoomFactor) ? 1
                    : this.chartSettings.primaryYAxis.zoomFactor;
                currentYAxis.rowIndex = 0;
                currentYAxis.columnIndex = 0;
                currentYAxis.edgeLabelPlacement = this.chartSettings.primaryYAxis.edgeLabelPlacement ?
                    this.chartSettings.primaryYAxis.edgeLabelPlacement : this.persistSettings.primaryYAxis.edgeLabelPlacement;
                if (!(this.chartSettings.chartSeries.type === 'Polar' || this.chartSettings.chartSeries.type === 'Radar')) {
                    currentYAxis.name = this.measuresNames[this.currentMeasure] ? this.measuresNames[this.currentMeasure] : this.currentMeasure;
                }
                currentYAxis.labelFormat = currentYAxis.labelFormat ? currentYAxis.labelFormat : (percentChart ? '' : format);
                currentYAxis.title = currentYAxis.title ? currentYAxis.title : measureAggregatedName;
                axes = axes.concat(currentYAxis);
                rows.push({ height: '100%' });
                columns.push({ width: '100%' });
            }
            return { axes: axes, rows: rows, columns: columns };
        };
        PivotChart.prototype.getFormat = function (format) {
            Eif (format === 'Currency') {
                format = 'C';
            }
            else if (format === 'Percent') {
                format = 'P';
            }
            else {
                format = 'N';
            }
            return format;
        };
        PivotChart.prototype.getColumnTotalIndex = function (pivotValues) {
            var colIndexColl = {};
            var rKeys = Object.keys(pivotValues);
            for (var _i = 0, rKeys_2 = rKeys; _i < rKeys_2.length; _i++) {
                var rowIndex = rKeys_2[_i];
                var rows = pivotValues[Number(rowIndex)];
                var cKeys = void 0;
                Eif (!ej2_base_1.isNullOrUndefined(rows)) {
                    cKeys = Object.keys(rows);
                    for (var _a = 0, cKeys_2 = cKeys; _a < cKeys_2.length; _a++) {
                        var cellIndex = cKeys_2[_a];
                        var cell = rows[Number(cellIndex)];
                        Eif (!ej2_base_1.isNullOrUndefined(cell)) {
                            if (cell.axis !== 'column') {
                                return colIndexColl;
                            }
                            else if ((cell.type === 'sum' || (this.dataSourceSettings && this.dataSourceSettings.columns &&
                                this.dataSourceSettings.columns.length === 0 ? false : cell.type === 'grand sum')) && cell.rowSpan !== -1) {
                                colIndexColl[cell.colIndex] = cell.colIndex;
                            }
                        }
                    }
                }
            }
            return colIndexColl;
        };
        PivotChart.prototype.groupHierarchyWithLevels = function (pivotValues, fieldPosition) {
            var _a, _b;
            var group = {};
            var fieldCount = 0;
            var levelPos = {};
            this.measurePos = this.engineModule.tupRowInfo[0].measurePosition;
            for (var rowPos = 0; rowPos < pivotValues.length; rowPos++) {
                var cell = pivotValues[rowPos][0];
                if (cell && cell.axis === 'row' && cell.type !== 'grand sum') {
                    if (ej2_base_1.isNullOrUndefined(group[cell.hierarchy])) {
                        Iif (cell.memberType === 3) {
                            if (fieldCount === this.measurePos) {
                                fieldPosition[this.measurePos] = cell.hierarchy;
                                group[cell.hierarchy] = (_a = {}, _a[cell.levelUniqueName] = cell.levelUniqueName, _a);
                            }
                            else {
                                fieldCount--;
                            }
                        }
                        else {
                            fieldPosition[fieldCount] = cell.hierarchy;
                            group[cell.hierarchy] = (_b = {}, _b[cell.levelUniqueName] = cell.levelUniqueName, _b);
                        }
                        fieldCount++;
                    }
                    else {
                        group[cell.hierarchy][cell.levelUniqueName] = cell.levelUniqueName;
                    }
                }
            }
            var lastEnd = -1;
            for (var pos = 0; pos < fieldPosition.length; pos++) {
                Eif (this.measurePos !== pos) {
                    levelPos[fieldPosition[pos]] = {
                        start: (lastEnd + 1),
                        end: (lastEnd + Object.keys(group[fieldPosition[pos]]).length)
                    };
                    lastEnd = levelPos[fieldPosition[pos]].end;
                }
            }
            return levelPos;
        };
        PivotChart.prototype.frameMultiLevelLabels = function () {
            var startKeys = Object.keys(this.headerColl);
            var parentHeaders = this.headerColl[-0.5];
            for (var _i = 0, startKeys_1 = startKeys; _i < startKeys_1.length; _i++) {
                var startKey = startKeys_1[_i];
                var sKey = Number(startKey);
                var headers = this.headerColl[sKey];
                var levelPos = 0;
                var isAvail = false;
                while (levelPos <= this.maxLevel) {
                    if (!isAvail) {
                        if (!headers[levelPos]) {
                            headers[levelPos] = parentHeaders[levelPos];
                        }
                        else {
                            isAvail = true;
                        }
                    }
                    else if (!headers[levelPos]) {
                        headers[levelPos] = {
                            name: headers[levelPos - 1].name,
                            text: '',
                            hasChild: headers[levelPos - 1].hasChild,
                            isDrilled: headers[levelPos - 1].isDrilled,
                            levelName: headers[levelPos - 1].levelName,
                            level: headers[levelPos - 1].level,
                            fieldName: headers[levelPos - 1].fieldName,
                            rowIndex: headers[levelPos - 1].rowIndex,
                            colIndex: headers[levelPos - 1].colIndex,
                            span: -1
                        };
                    }
                    levelPos++;
                }
                parentHeaders = this.headerColl[sKey];
            }
            var gRows = {};
            for (var _a = 0, startKeys_2 = startKeys; _a < startKeys_2.length; _a++) {
                var startKey = startKeys_2[_a];
                var sKey = Number(startKey);
                var headers = this.headerColl[sKey];
                var lKeys = Object.keys(headers);
                for (var _b = 0, lKeys_1 = lKeys; _b < lKeys_1.length; _b++) {
                    var levelKey = lKeys_1[_b];
                    var lKey = Number(levelKey);
                    if (gRows[lKey]) {
                        var len = gRows[lKey].length;
                        if (headers[lKey].levelName === parentHeaders[lKey].levelName) {
                            gRows[lKey][len - 1].end = gRows[lKey][len - 1].end + 1;
                        }
                        else {
                            gRows[lKey].push({
                                start: sKey, end: sKey + 1, text: headers[lKey].text,
                                type: (headers[lKey].span === -1 ? 'WithoutTopandBottomBorder' : 'WithoutTopBorder'),
                                customAttributes: headers[lKey]
                            });
                        }
                    }
                    else {
                        gRows[lKey] = [{
                                start: sKey, end: sKey + 1, text: headers[lKey].text,
                                type: (headers[lKey].span === -1 ? 'WithoutTopandBottomBorder' : 'WithoutTopBorder'),
                                customAttributes: headers[lKey]
                            }];
                    }
                }
                parentHeaders = headers;
            }
            var levellength = Object.keys(gRows).length;
            var multiLevelLabels = [];
            for (var level = levellength - 1; level > -1; level--) {
                multiLevelLabels.push({ categories: gRows[level], border: { width: 1 }, overflow: 'Trim' });
            }
            return multiLevelLabels;
        };
        PivotChart.prototype.getZoomFactor = function () {
            this.calculatedWidth = this.getCalulatedWidth();
            var seriesLength = (this.chartSeries.length * 10) > 120 ? (this.chartSeries.length * 10) : 120;
            var zoomFactor = this.chartSeries.length > 0 ?
                (this.calculatedWidth / (Object.keys(this.chartSeries[0].dataSource).length * seriesLength)) : 1;
            zoomFactor = (zoomFactor < 1 && zoomFactor > 0) ? zoomFactor : 1;
            return zoomFactor;
        };
        PivotChart.prototype.getCalulatedWidth = function () {
            if (!isNaN(Number(this.parent.width))) {
                this.calculatedWidth = Number(this.parent.width);
            }
            else if (this.parent.width.indexOf('%') > -1) {
                this.calculatedWidth = this.parent.element.clientWidth * (parseFloat(this.parent.width) / 100);
            }
            else if (this.parent.width.indexOf('px') > -1) {
                this.calculatedWidth = Number(this.parent.width.toString().split('px')[0]);
            }
            else {
                this.calculatedWidth = this.parent.element.clientWidth;
            }
            return this.calculatedWidth;
        };
        PivotChart.prototype.configTooltipSettings = function () {
            var tooltip = this.persistSettings.tooltip ? this.persistSettings.tooltip :
                this.chartSettings.tooltip;
            tooltip.enable = tooltip.enable === undefined ? true : tooltip.enable;
            Iif (tooltip.enable && tooltip.template) {
                this.templateFn = this.parent.templateParser(tooltip.template);
            }
            Iif (this.parent.tooltipTemplate) {
                tooltip.template = tooltip.template ? tooltip.template : this.parent.tooltipTemplate;
            }
            tooltip.header = tooltip.header ? tooltip.header : '';
            tooltip.enableMarker = tooltip.enableMarker === undefined ? true : tooltip.enableMarker;
            return tooltip;
        };
        PivotChart.prototype.configLegendSettings = function () {
            var legendSettings = {};
            if (this.chartSettings.legendSettings) {
                var keyPos = 0;
                var keys = Object.keys(this.chartSettings.legendSettings);
                while (keyPos < keys.length) {
                    legendSettings[keys[keyPos]] = this.chartSettings.legendSettings[keys[keyPos]];
                    keyPos++;
                }
            }
            legendSettings.visible = legendSettings.visible !== false;
            legendSettings.padding = legendSettings.padding ? legendSettings.padding : 25;
            legendSettings.shapePadding = legendSettings.shapePadding ? legendSettings.shapePadding : 10;
            return legendSettings;
        };
        PivotChart.prototype.configXAxis = function () {
            var currentXAxis = {};
            currentXAxis = this.persistSettings.primaryXAxis ? this.frameObjectWithKeys(this.persistSettings.primaryXAxis) : currentXAxis;
            currentXAxis.valueType = 'Category';
            currentXAxis.labelIntersectAction = currentXAxis.labelIntersectAction ? currentXAxis.labelIntersectAction : 'Rotate45';
            currentXAxis.title = currentXAxis.title ? currentXAxis.title :
                this.dataSourceSettings.rows.map(function (args) {
                    return args.caption || args.name;
                }).join(' / ');
            currentXAxis.zoomFactor = ej2_base_1.isNullOrUndefined(this.parent.chartSettings.primaryXAxis.zoomFactor) ? this.getZoomFactor()
                : this.parent.chartSettings.primaryXAxis.zoomFactor;
            if (!this.parent.chartSettings.zoomSettings.enableScrollbar) {
                currentXAxis.zoomFactor = 1;
            }
            Eif (this.chartSettings.showMultiLevelLabels && this.chartSettings.chartSeries.type !== 'Pareto') {
                currentXAxis.multiLevelLabels = this.frameMultiLevelLabels();
                currentXAxis.border = { width: 1, type: 'WithoutTopandBottomBorder' };
                currentXAxis.majorTickLines = { width: 0, height: -10 };
            }
            else {
                currentXAxis.multiLevelLabels = [];
                currentXAxis.border = { width: 1, type: 'Rectangle' };
                currentXAxis.majorTickLines = { width: 0, height: 5 };
            }
            return currentXAxis;
        };
        PivotChart.prototype.configZoomSettings = function () {
            var zoomSettings = this.chartSettings.zoomSettings;
            zoomSettings.enableSelectionZooming = zoomSettings.enableSelectionZooming === undefined ? true :
                zoomSettings.enableSelectionZooming;
            zoomSettings.enableScrollbar = zoomSettings.enableScrollbar === undefined ? true : zoomSettings.enableScrollbar;
            return zoomSettings;
        };
        PivotChart.prototype.tooltipRender = function (args) {
            var measure = (this.chartSettings.enableMultipleAxis && this.chartSettings.multipleAxisMode === 'Combined' &&
                this.accumulationType.indexOf(this.chartSettings.chartSeries.type) < 0 && this.chartSettings.chartSeries.type !== 'Radar' &&
                this.chartSettings.chartSeries.type !== 'Polar') ? args.series.tooltipMappingName :
                args.series.yAxisName ? (args.series.yAxisName.split('_CumulativeAxis')[0]) :
                    ((this.chartSettings.enableMultipleAxis && this.accumulationType.indexOf(this.chartSettings.chartSeries.type) < 0 &&
                        this.chartSettings.chartSeries.type !== 'Pareto') ? args.series.name ? args.series.name.split(' | ')[1] :
                        args.data.seriesName ? args.data.seriesName.split(' | ')[1] : this.currentMeasure : this.measuresNames[this.currentMeasure] ?
                        this.measuresNames[this.currentMeasure] : this.currentMeasure);
            var dataSource = args.series.dataSource ? args.series.dataSource
                : this.parent.chart.series[args.data.seriesIndex].dataSource;
            var rowIndex = dataSource ? dataSource[args.data.pointIndex].rIndex : undefined;
            var colIndex = dataSource ? dataSource[args.data.pointIndex].cIndex : undefined;
            var measureField = this.engineModule.fieldList[this.measuresNames[measure]
                ? this.measuresNames[measure] : measure];
            var aggregateType = this.parent.dataType === 'olap' ? '' : this.parent.localeObj.getConstant(measureField.aggregateType);
            var measureAggregatedName = (this.parent.dataType === 'olap' ? '' : aggregateType + ' ' +
                this.parent.localeObj.getConstant('of') + ' ') + measureField.caption;
            var formattedText = this.engineModule.pivotValues[rowIndex][colIndex].formattedText;
            var formatField = this.engineModule.formatFields[measureField.id];
            var valueFormat = this.engineModule.getFormattedValue(args.point.y, measureField.id, formattedText);
            var formattedValue = (formatField && formatField.format && formatField.format.toLowerCase().match(/n|p|c/) !== null &&
                this.chartSettings.useGroupingSeparator) ? this.parent.dataType === 'olap' ?
                valueFormat.toString() : valueFormat.formattedText :
                formattedText;
            var text = this.parent.pivotValues[rowIndex][colIndex].columnHeaders;
            var columnText = '';
            if (ej2_base_1.isNullOrUndefined(text)) {
                columnText = undefined;
            }
            else if (this.parent.dataType === 'olap') {
                columnText = this.chartSeriesInfo[text.toString().split(/~~|::/).join(' - ')].uniqueName;
            }
            else {
                var values = text.toString().split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter);
                text = util_1.PivotUtil.formatChartHeaders(values, this, true);
                columnText = this.chartSeriesInfo[text.toString()].uniqueName;
            }
            var rowText = args.point.x;
            if (this.parent.tooltipTemplate && this.parent.getTooltipTemplate() !== undefined || this.chartSettings.tooltip.template) {
                var rowFields = dataSource ? this.parent.getHeaderField(rowIndex, colIndex, 'row') : '';
                var columnFields = dataSource ? this.parent.getHeaderField(rowIndex, colIndex, 'Column') : '';
                var templateVariable = {
                    rowHeaders: rowText,
                    columnHeaders: columnText,
                    aggregateType: aggregateType,
                    value: formattedValue,
                    valueField: measureField.caption,
                    rowFields: rowFields,
                    columnFields: columnFields
                };
                var template = void 0;
                if (this.parent.chartSettings && this.parent.chartSettings.tooltip &&
                    this.parent.chartSettings.tooltip.enable && this.parent.chartSettings.tooltip.template) {
                    template = this.tooltipTemplateFn()(templateVariable, this, 'tooltipTemplate', this.element.id + '1tooltipTemplate')[0].outerHTML;
                }
                else {
                    template = this.parent.getTooltipTemplate()(templateVariable, this, 'tooltipTemplate', this.element.id + 'tooltipTemplate')[0].outerHTML;
                }
                args.template = template;
            }
            else {
                args.text = measureAggregatedName + ': ' + formattedValue +
                    (this.dataSourceSettings.columns.length === 0 ? '' :
                        (' <br/>' + this.parent.localeObj.getConstant('column') + ': ' + columnText)) +
                    (this.dataSourceSettings.rows.length === 0 ? '' :
                        (' <br/>' + this.parent.localeObj.getConstant('row') + ': ' + rowText)) +
                    ((args.data && args.data.seriesName === 'Pareto') ?
                        " <br/>" + this.parent.localeObj.getConstant('pareto') + ": " + args.data.pointY + "%" : '');
                this.parent.trigger(events.chartTooltipRender, args);
            }
        };
        PivotChart.prototype.tooltipTemplateFn = function () {
            return this.templateFn;
        };
        PivotChart.prototype.loaded = function (args) {
            this.parent.isChartLoaded = true;
            var width = this.parent.grid ? this.parent.getGridWidthAsNumber().toString() : this.parent.getWidthAsNumber().toString();
            if (this.parent.chart && this.parent.showGroupingBar && this.parent.groupingBarModule &&
                this.parent.showFieldList && this.parent.currentView === 'Chart') {
                this.parent.groupingBarModule.alignIcon();
            }
            Eif (this.chartSettings.showMultiLevelLabels) {
                var multilabelAxisName = util_1.PivotUtil.inArray(this.chartSettings.chartSeries.type, ['Bar', 'StackingBar', 'StackingBar100']) > -1 ?
                    '_chartYAxisMultiLevelLabel0' : '_chartXAxisMultiLevelLabel0';
                if (!ej2_base_1.isNullOrUndefined(ej2_base_1.select('#' + this.parent.element.id + multilabelAxisName, this.parent.element))) {
                    this.parent.element.querySelector('#' + this.parent.element.id + multilabelAxisName).setAttribute('cursor', 'pointer');
                }
            }
            var height = this.getChartHeight();
            this.parent.chart.height = height;
            if (this.parent.chartSettings.enableScrollOnMultiAxis && this.parent.chartSettings.enableMultipleAxis) {
                Iif (['Pie', 'Funnel', 'Pyramid', 'Doughnut', 'Radar', 'Polar', 'Pareto'].indexOf(this.parent.chartSettings.chartSeries.type) >= 0) {
                    this.parent.element.querySelector('.' + cls.PIVOTCHART).style.overflow = 'visible';
                }
                else {
                    this.parent.element.querySelector('.' + cls.PIVOTCHART).style.overflow = 'auto';
                    this.parent.element.querySelector('.' + cls.PIVOTCHART).style.overflowX = 'hidden';
                }
                this.parent.element.querySelector('.' + cls.PIVOTCHART).style.width = width + 'px';
                this.parent.element.querySelector('.' + cls.PIVOTCHART).style.height = height + 'px';
            }
            this.updateView();
            if (this.parent.displayOption.primary === 'Chart' || this.parent.displayOption.view === 'Chart') {
                this.parent.notify(events.contentReady, {});
            }
            this.parent.trigger(events.chartLoaded, args);
            Eif ((this.parent.dataSourceSettings.mode === 'Server' && this.parent.isServerWaitingPopup) || this.parent.dataSourceSettings.mode === 'Local') {
                this.parent.hideWaitingPopup();
            }
        };
        PivotChart.prototype.updateView = function () {
            if (this.parent.grid && this.parent.chart && this.parent.showToolbar) {
                var groupingTable = this.parent.element.querySelector('.e-pivot-grouping-bar');
                var groupingChartTable = this.parent.element.querySelector('.e-chart-grouping-bar');
                if (this.parent.currentView === 'Table') {
                    this.parent.grid.element.style.display = '';
                    this.parent.chart.element.style.display = 'none';
                    if (this.parent.showGroupingBar && this.parent.groupingBarModule) {
                        Eif (groupingTable) {
                            groupingTable.style.display = '';
                            Iif (groupingTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) &&
                                this.parent.groupingBarModule.gridPanel != null && !this.parent.groupingBarModule.gridPanel.isDestroyed) {
                                this.parent.groupingBarModule.gridPanel.refreshOverflow();
                            }
                        }
                        Eif (groupingChartTable) {
                            groupingChartTable.style.display = 'none';
                        }
                    }
                    if (this.parent.chartSettings.enableMultipleAxis && this.parent.chartSettings.enableScrollOnMultiAxis) {
                        this.parent.element.querySelector('.e-pivotchart').style.display = 'none';
                    }
                }
                else {
                    this.parent.grid.element.style.display = 'none';
                    this.parent.chart.element.style.display = '';
                    if (this.parent.showGroupingBar && this.parent.groupingBarModule) {
                        Eif (groupingTable) {
                            groupingTable.style.display = 'none';
                        }
                        Eif (groupingChartTable) {
                            groupingChartTable.style.display = '';
                            Iif (groupingChartTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) &&
                                this.parent.groupingBarModule.chartPanel != null && !this.parent.groupingBarModule.chartPanel.isDestroyed) {
                                this.parent.groupingBarModule.chartPanel.refreshOverflow();
                            }
                        }
                    }
                    if (this.parent.chartSettings.enableMultipleAxis && this.parent.chartSettings.enableScrollOnMultiAxis) {
                        this.parent.element.querySelector('.e-pivotchart').style.display = '';
                    }
                }
            }
        };
        PivotChart.prototype.creatMenu = function () {
            if (this.accumulationMenu && !this.accumulationMenu.isDestroyed) {
                this.accumulationMenu.destroy();
            }
            var items = ((this.parent.allowDrillThrough || this.parent.editSettings.allowEditing)
                && this.parent.drillThroughModule) ? ['expand', 'collapse', 'drillThrough', 'exit'] :
                ['expand', 'collapse', 'exit'];
            var option = [];
            for (var i = 0; i < items.length; i++) {
                option.push({
                    id: this.parent.element.id + '_DrillMenuChart_' + items[i],
                    text: this.parent.localeObj.getConstant(items[i]),
                    items: []
                });
            }
            var getString = this.getMenuItems();
            var expand = [];
            var collapse = [];
            for (var i = 0; i < getString.length; i++) {
                if (getString[i].type === 'expand') {
                    expand.push({ id: this.element.id + 'drillExpand_' + getString[i].key, text: getString[i].value });
                }
                else {
                    collapse.push({ id: this.element.id + 'drillCollapse_' + getString[i].key, text: getString[i].value });
                }
            }
            if (expand.length > 0) {
                option[0].items = expand;
            }
            if (collapse.length > 0) {
                option[1].items = collapse;
            }
            var menuOptions = {
                cssClass: this.parent.element.id + '_accumulationChart' + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                items: option,
                enableRtl: this.parent.enableRtl,
                beforeOpen: this.drillMenuOpen.bind(this),
                select: this.drillMenuSelect.bind(this),
                locale: this.parent.locale
            };
            this.accumulationMenu = new ej2_navigations_1.ContextMenu(menuOptions);
            var contextMenu;
            if (ej2_base_1.select('#' + this.parent.element.id + '_accumulationChart', this.parent.element)) {
                contextMenu = ej2_base_1.select('#' + this.parent.element.id + '_accumulationChart', this.parent.element);
                contextMenu.innerHTML = '';
            }
            else {
                contextMenu = ej2_base_1.createElement('ul', {
                    id: this.parent.element.id + '_accumulationChart'
                });
                this.parent.element.appendChild(contextMenu);
            }
            this.accumulationMenu.isStringTemplate = true;
            this.accumulationMenu.appendTo(contextMenu);
        };
        PivotChart.prototype.drillMenuOpen = function (args) {
            if (args.items[0] && args.items[0].text === this.parent.localeObj.getConstant('expand') &&
                args.items[0].items && args.items[0].items.length === 0) {
                this.accumulationMenu.enableItems([this.parent.localeObj.getConstant('expand')], false);
            }
            if (args.items[1] && args.items[1].text === this.parent.localeObj.getConstant('collapse') &&
                args.items[1].items && args.items[1].items.length === 0) {
                this.accumulationMenu.enableItems([this.parent.localeObj.getConstant('collapse')], false);
            }
        };
        PivotChart.prototype.getMenuItems = function () {
            var rowIndex = this.pivotIndex.rIndex;
            var menuItem = [];
            var pivotValues = this.engineModule.pivotValues;
            var levelCol = [];
            var pivotValue = pivotValues[rowIndex][this.pivotIndex.cIndex];
            var level = (!pivotValues[rowIndex][0].isNamedSet && pivotValues[rowIndex][0].hasChild) ?
                pivotValues[rowIndex][0].level : undefined;
            var levels = this.parent.dataType === 'olap' ? pivotValue.rowHeaders.toString().split(/~~|::/)
                : pivotValue.rowHeaders.toString().split(this.engineModule.valueSortSettings.headerDelimiter);
            while (pivotValues[rowIndex][0]) {
                pivotValue = pivotValues[rowIndex][0];
                if ((levels.length !== 0) && (levels.indexOf(pivotValue.formattedText.toString()) === (levels.length - 1))) {
                    if (pivotValue.hasChild && !pivotValue.isNamedSet && levelCol.indexOf(pivotValue.level) < 0 &&
                        (level ? level >= pivotValue.level : (level === 0 ? (pivotValue.level === 0) : true))) {
                        if (!(pivotValue.isDrilled && pivotValue.hasChild)) {
                            menuItem.push({
                                key: rowIndex,
                                type: 'expand',
                                value: pivotValue.formattedText
                            });
                        }
                        else {
                            menuItem.push({
                                key: rowIndex,
                                type: 'collapse',
                                value: pivotValue.formattedText
                            });
                        }
                        levelCol.push(pivotValue.level);
                        level = level ? (level - 1) : (pivotValue.level - 1);
                    }
                    var index = levels.indexOf(pivotValue.formattedText.toString());
                    levels.splice(index, 1);
                }
                if (pivotValue.level === 0 && pivotValue.hasChild && !pivotValue.isNamedSet) {
                    level = undefined;
                    levelCol = [];
                }
                rowIndex--;
            }
            return menuItem;
        };
        PivotChart.prototype.drillMenuSelect = function (args) {
            var pivotValues = (this.parent.dataType === 'olap' ?
                this.parent.olapEngineModule.pivotValues : this.parent.engineModule.pivotValues);
            var option = (args.element.id).split('_DrillMenuChart_')[1];
            if (args.element.id.indexOf(this.element.id + 'drill') === 0) {
                var type = args.element.id.split(this.element.id + 'drill')[1].indexOf('Expand') >= 0 ? 'drillExpand' : 'drillCollapse';
                var rowIndex = Number(args.element.id.split(this.element.id + type + '_')[1]);
                var pivotValue = pivotValues[rowIndex][0];
                var name_2 = this.parent.dataType === 'olap' ? pivotValue.formattedText :
                    (pivotValue.actualText ? pivotValue.actualText.toString() : pivotValue.formattedText.toString());
                var text = pivotValue.formattedText ? pivotValue.formattedText.toString() : name_2;
                var caption = (pivotValue.hasChild && !pivotValue.isNamedSet) ?
                    ((pivotValue.isDrilled ? ' - ' : ' + ') + text) : text;
                var tupInfo = this.parent.dataType === 'olap' ?
                    this.engineModule.tupRowInfo[pivotValue.ordinal] : undefined;
                var levelName = tupInfo ? tupInfo.uNameCollection : pivotValue.valueSort.levelName.toString();
                var customAttributes = {
                    fieldName: pivotValue.valueSort.axis,
                    level: pivotValue.level,
                    hasChild: pivotValue.hasChild,
                    levelName: levelName,
                    name: name_2,
                    text: caption,
                    rowIndex: rowIndex,
                    colIndex: 0,
                    isDrilled: pivotValue.isDrilled,
                    cell: pivotValue
                };
                if (this.parent.dataType === 'olap') {
                    this.parent.onDrill(undefined, customAttributes);
                }
                else {
                    this.onDrill({ customAttributes: customAttributes });
                }
            }
            else if (option === 'drillThrough') {
                this.parent.drillThroughModule.executeDrillThrough(pivotValues[this.pivotIndex.rIndex][this.pivotIndex.cIndex], this.pivotIndex.rIndex, this.pivotIndex.rIndex);
            }
            else if (option === 'exit') {
                this.accumulationMenu.close();
            }
        };
        PivotChart.prototype.getChartHeight = function () {
            var height;
            var offSetHeight;
            Iif (ej2_base_1.isNullOrUndefined(this.parent.getHeightAsNumber())) {
                height = 'auto';
            }
            else {
                var offSetVal = this.parent.showToolbar ? 6 : 5;
                height = (this.parent.getHeightAsNumber() - offSetVal).toString();
                offSetHeight = this.parent.getHeightAsNumber() - offSetVal;
            }
            Eif (!ej2_base_1.isNullOrUndefined(this.parent.getHeightAsNumber())) {
                var isNone = false;
                if (this.parent.element.querySelector('.e-chart-grouping-bar') !== null && this.parent.element.querySelector('.e-chart-grouping-bar').style.display.toLowerCase() === 'none') {
                    isNone = true;
                    this.parent.element.querySelector('.e-chart-grouping-bar').style.display = 'block';
                }
                if (this.parent.showToolbar && this.parent.showGroupingBar) {
                    height = (offSetHeight - (this.parent.element.querySelector('.e-pivot-toolbar') ?
                        this.parent.element.querySelector('.e-pivot-toolbar').clientHeight : 42) -
                        (this.parent.element.querySelector('.e-chart-grouping-bar') ?
                            this.parent.element.querySelector('.e-chart-grouping-bar').clientHeight : 62)).toString();
                }
                else if (this.parent.showToolbar) {
                    height = (offSetHeight - (this.parent.element.querySelector('.e-pivot-toolbar') ?
                        this.parent.element.querySelector('.e-pivot-toolbar').clientHeight : 42)).toString();
                }
                else if (this.parent.showGroupingBar) {
                    height = (offSetHeight - (this.parent.element.querySelector('.e-chart-grouping-bar') ?
                        this.parent.element.querySelector('.e-chart-grouping-bar').clientHeight : 62)).toString();
                }
                else Iif ((this.parent.chart && parseInt(this.parent.chart.height, 10) < 200) || offSetHeight < 200) {
                    height = '200';
                }
                if (isNone) {
                    this.parent.element.querySelector('.e-chart-grouping-bar').style.display = 'none';
                }
            }
            else {
                height = 'auto';
            }
            return height;
        };
        PivotChart.prototype.getChartAutoHeight = function () {
            var height = this.parent.element.offsetHeight < this.parent.minHeight ? this.parent.minHeight :
                this.parent.element.offsetHeight;
            if (this.parent.showToolbar && this.parent.showGroupingBar) {
                height = height - (this.parent.element.querySelector('.e-pivot-toolbar') ?
                    this.parent.element.querySelector('.e-pivot-toolbar').clientHeight : 42) -
                    (this.parent.element.querySelector('.e-chart-grouping-bar') ?
                        this.parent.element.querySelector('.e-chart-grouping-bar').clientHeight : 62);
            }
            else if (this.parent.showToolbar) {
                height = height - (this.parent.element.querySelector('.e-pivot-toolbar') ?
                    this.parent.element.querySelector('.e-pivot-toolbar').clientHeight : 42);
            }
            else if (this.parent.showGroupingBar) {
                height = height - (this.parent.element.querySelector('.e-chart-grouping-bar') ?
                    this.parent.element.querySelector('.e-chart-grouping-bar').clientHeight : 62);
            }
            return height;
        };
        PivotChart.prototype.axisLabelRender = function (args) {
            Eif (this.chartSettings.showMultiLevelLabels && this.chartSettings.chartSeries.type !== 'Pareto') {
                if (args.axis.name === 'primaryXAxis') {
                    args.text = '';
                }
            }
            if (args.axis.name !== 'primaryXAxis') {
                var formatField = this.engineModule.formatFields[(this.chartSettings.enableMultipleAxis &&
                    this.chartSettings.multipleAxisMode === 'Combined') ? this.currentMeasure : args.axis.name];
                var valueFormat = this.engineModule.getFormattedValue(args.value, (this.chartSettings.enableMultipleAxis &&
                    this.chartSettings.multipleAxisMode === 'Combined') ? this.currentMeasure : args.axis.name, args.text);
                var formattedValue = ((formatField && formatField.format && formatField.format.toLowerCase().match(/n|p|c/) !== null &&
                    this.chartSettings.useGroupingSeparator) ? this.parent.dataType === 'olap' ? valueFormat.toString() :
                    valueFormat.formattedText : args.value.toString());
                args.text = formattedValue;
            }
            this.parent.trigger(events.chartAxisLabelRender, args);
        };
        PivotChart.prototype.multiLevelLabelClick = function (args) {
            var eventArgs = {
                axis: args.axis,
                text: args.text,
                cell: !ej2_base_1.isNullOrUndefined(args.customAttributes) ? args.customAttributes.cell : undefined,
                cancel: false
            };
            this.parent.trigger(events.multiLevelLabelClick, eventArgs);
            Eif (!eventArgs.cancel && args.customAttributes && args.customAttributes.hasChild &&
                !args.customAttributes.cell.isNamedSet) {
                Iif (this.parent.dataType === 'olap') {
                    this.parent.onDrill(undefined, args.customAttributes);
                }
                else {
                    this.onDrill(args);
                }
            }
        };
        PivotChart.prototype.onDrill = function (args) {
            var labelInfo = args.customAttributes;
            var delimiter = (this.dataSourceSettings.drilledMembers[0] && this.dataSourceSettings.drilledMembers[0].delimiter) ?
                this.dataSourceSettings.drilledMembers[0].delimiter : '**';
            var fieldName = labelInfo.fieldName;
            var currentCell = this.engineModule.pivotValues[labelInfo.rowIndex][labelInfo.colIndex];
            var memberUqName = currentCell.valueSort.levelName.
                split(this.engineModule.valueSortSettings.headerDelimiter).join(delimiter);
            var fieldAvail = false;
            if (this.dataSourceSettings.drilledMembers.length === 0) {
                this.parent.setProperties({
                    dataSourceSettings: { drilledMembers: [{ name: fieldName, items: [memberUqName], delimiter: delimiter }] }
                }, true);
            }
            else {
                for (var fCnt = 0; fCnt < this.dataSourceSettings.drilledMembers.length; fCnt++) {
                    var field = this.dataSourceSettings.drilledMembers[fCnt];
                    memberUqName = memberUqName.split(delimiter).join(field.delimiter ? field.delimiter : delimiter);
                    delimiter = field.delimiter = field.delimiter ? field.delimiter : delimiter;
                    Eif (field.name === fieldName) {
                        fieldAvail = true;
                        var memIndex = field.items.indexOf(memberUqName);
                        Eif (memIndex > -1) {
                            field.items.splice(memIndex, 1);
                        }
                        else {
                            field.items.push(memberUqName);
                        }
                    }
                    else {
                        continue;
                    }
                }
                Iif (!fieldAvail) {
                    this.dataSourceSettings.drilledMembers.push({ name: fieldName, items: [memberUqName], delimiter: delimiter });
                }
            }
            this.parent.showWaitingPopup();
            var pivot = this;
            var drilledItem = {
                fieldName: fieldName, memberName: memberUqName, delimiter: delimiter,
                axis: 'row',
                action: labelInfo.isDrilled ? 'up' : 'down',
                currentCell: currentCell
            };
            var drillArgs = {
                drillInfo: drilledItem,
                pivotview: pivot.parent
            };
            pivot.parent.trigger(events.drill, drillArgs);
            var enginePopulatingEventArgs = {
                dataSourceSettings: util_1.PivotUtil.getClonedDataSourceSettings(this.parent.dataSourceSettings)
            };
            this.parent.trigger(events.enginePopulating, enginePopulatingEventArgs);
            this.parent.setProperties({ dataSourceSettings: enginePopulatingEventArgs.dataSourceSettings }, true);
            Iif (pivot.parent.enableVirtualization || pivot.parent.enablePaging) {
                if (pivot.parent.dataSourceSettings.mode === 'Server') {
                    pivot.parent.getEngine('onDrill', drilledItem, null, null, null, null, null);
                }
                else {
                    pivot.engineModule.drilledMembers = pivot.dataSourceSettings.drilledMembers;
                    pivot.engineModule.onDrill(drilledItem);
                }
            }
            else Iif (pivot.parent.dataSourceSettings.mode === 'Server') {
                pivot.parent.getEngine('onDrill', drilledItem, null, null, null, null, null);
            }
            else {
                pivot.engineModule.generateGridData(pivot.dataSourceSettings, true);
            }
            pivot.parent.allowServerDataBinding = false;
            pivot.parent.setProperties({ pivotValues: pivot.engineModule.pivotValues }, true);
            pivot.parent.allowServerDataBinding = true;
            var eventArgs = {
                dataSourceSettings: util_1.PivotUtil.getClonedDataSourceSettings(this.parent.dataSourceSettings),
                pivotValues: this.parent.pivotValues
            };
            this.parent.trigger(events.enginePopulated, eventArgs);
            pivot.engineModule.pivotValues = eventArgs.pivotValues;
            pivot.parent.renderPivotGrid();
        };
        PivotChart.prototype.isAttributeDrill = function (hierarchy, drillInfo) {
            var isDrill = false;
            for (var i = 0; i < this.dataSourceSettings.drilledMembers.length; i++) {
                Iif (this.dataSourceSettings.drilledMembers[i].name === hierarchy) {
                    for (var j = 0; j < this.dataSourceSettings.drilledMembers[i].items.length; j++) {
                        var drillItems = this.dataSourceSettings.drilledMembers[i].items[j]
                            .split(this.dataSourceSettings.drilledMembers[i].delimiter);
                        var levelName = '';
                        for (var k = 0; k < drillItems.length; k++) {
                            if (drillInfo[k] && drillInfo[k].uName) {
                                levelName = levelName + (levelName === '' ? '' : this.dataSourceSettings.drilledMembers[i].delimiter) +
                                    (drillInfo[k].uName.indexOf('[Measures]') > -1 ? '[Measures]' : drillInfo[k].uName);
                            }
                        }
                        if (levelName === this.dataSourceSettings.drilledMembers[i].items[j]) {
                            isDrill = true;
                            break;
                        }
                    }
                }
            }
            return isDrill;
        };
        PivotChart.prototype.load = function (args) {
            if (args.chart.zoomModule) {
                args.chart.zoomModule.isZoomed = true;
            }
            this.parent.trigger(events.chartLoad, args);
        };
        PivotChart.prototype.beforePrint = function (args) {
            this.parent.trigger(events.beforePrint, args);
        };
        PivotChart.prototype.animationComplete = function (args) {
            this.parent.trigger(events.animationComplete, args);
        };
        PivotChart.prototype.legendRender = function (args) {
            this.parent.trigger(events.legendRender, args);
        };
        PivotChart.prototype.textRender = function (args) {
            this.parent.trigger(events.textRender, args);
        };
        PivotChart.prototype.pointRender = function (args) {
            this.parent.trigger(events.pointRender, args);
        };
        PivotChart.prototype.seriesRender = function (args) {
            this.parent.trigger(events.seriesRender, args);
        };
        PivotChart.prototype.chartMouseMove = function (args) {
            this.parent.trigger(events.chartMouseMove, args);
        };
        PivotChart.prototype.chartMouseClick = function (args) {
            this.parent.trigger(events.chartMouseClick, args);
        };
        PivotChart.prototype.pointMove = function (args) {
            this.parent.trigger(events.pointMove, args);
        };
        PivotChart.prototype.chartMouseLeave = function (args) {
            this.parent.trigger(events.chartMouseLeave, args);
        };
        PivotChart.prototype.chartMouseDown = function (args) {
            this.parent.trigger(events.chartMouseDown, args);
        };
        PivotChart.prototype.chartMouseUp = function (args) {
            this.parent.trigger(events.chartMouseUp, args);
        };
        PivotChart.prototype.dragComplete = function (args) {
            this.parent.trigger(events.dragComplete, args);
        };
        PivotChart.prototype.zoomComplete = function (args) {
            this.parent.trigger(events.zoomComplete, args);
        };
        PivotChart.prototype.scrollStart = function (args) {
            this.parent.trigger(events.scrollStart, args);
        };
        PivotChart.prototype.scrollEnd = function (args) {
            this.parent.trigger(events.scrollEnd, args);
        };
        PivotChart.prototype.scrollChanged = function (args) {
            this.parent.trigger(events.scrollChanged, args);
        };
        PivotChart.prototype.multiLevelLabelRender = function (args) {
            this.parent.trigger(events.multiLevelLabelRender, args);
        };
        PivotChart.prototype.resized = function (args) {
            Eif (this.accumulationType.indexOf(this.chartSettings.chartSeries.type) < 0) {
                args.chart.primaryXAxis.zoomFactor = ej2_base_1.isNullOrUndefined(this.parent.chartSettings.primaryXAxis.zoomFactor)
                    ? this.getZoomFactor() : this.parent.chartSettings.primaryXAxis.zoomFactor;
                Iif (!this.parent.chartSettings.zoomSettings.enableScrollbar) {
                    args.chart.primaryXAxis.zoomFactor = ej2_base_1.isNullOrUndefined(this.parent.chartSettings.primaryXAxis.zoomFactor)
                        ? 1 : this.parent.chartSettings.primaryXAxis.zoomFactor;
                }
            }
            this.parent.trigger(events.chartResized, args);
        };
        PivotChart.prototype.getResizedChartHeight = function () {
            var height = ['Pie', 'Funnel', 'Pyramid', 'Doughnut', 'Radar', 'Polar', 'Pareto'].indexOf(this.parent.chartSettings.chartSeries.type) < 0 &&
                this.parent.chartSettings.enableScrollOnMultiAxis && this.parent.chartSettings.enableMultipleAxis &&
                this.parent.dataSourceSettings.values.length > 0 ? Number(this.parent.chart.height) >
                (this.parent.dataSourceSettings.values.length * 235) + 100 ? isNaN(Number(this.getChartHeight())) ?
                this.getChartHeight().toString() : (Number(this.getChartHeight()) - 5).toString() :
                (!isNaN(Number(this.getChartHeight())) || this.parent.dataSourceSettings.values.length > 1) ?
                    ((this.parent.dataSourceSettings.values.length * 235) + 100).toString() : this.getChartHeight().toString()
                : this.getChartHeight().toString();
            return height;
        };
        PivotChart.prototype.destroy = function () {
            Iif (this.parent && this.parent.isDestroyed) {
                return;
            }
            if (this.engineModule && !this.parent.destroyEngine) {
                this.engineModule.fieldList = {};
                this.engineModule = {};
            }
            if (this.chartSeries) {
                this.chartSeries = null;
            }
            Eif (this.columnGroupObject) {
                this.columnGroupObject = null;
            }
            Eif (this.chartSeriesInfo) {
                this.chartSeriesInfo = {};
                this.selectedLegend = null;
            }
            if (this.chartSettings) {
                this.chartSettings = null;
            }
            if (this.dataSourceSettings) {
                this.dataSourceSettings = null;
            }
            Iif (this.accumulationMenu && !this.accumulationMenu.isDestroyed) {
                this.accumulationMenu.destroy();
                this.accumulationMenu = null;
            }
            Iif (this.parent && this.parent.chart && !this.parent.chart.isDestroyed) {
                this.parent.chart.destroy();
                this.parent.chart = null;
            }
            else {
                return;
            }
        };
        return PivotChart;
    }());
    exports.PivotChart = PivotChart;
});