all files / chart3d/series/ chart-series.js

97.54% Statements 475/487
85.06% Branches 222/261
97.87% Functions 46/47
97.91% Lines 468/478
18 statements, 7 functions, 29 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736              174×                                                     25×             9739× 9739× 9739×     267× 267× 267× 267× 267× 267× 267× 267×   1390× 1390× 1390× 1390×   1390× 1390× 1390× 1390× 1390× 1390× 1390× 1390× 376× 2130× 2130× 2130× 2130× 2130×     1014× 384×       384× 384× 384× 2136× 2136× 2136× 2136× 2014×     122×   2136× 2136×         2136×       630× 4083× 4083× 4083× 4083× 4083×       8349× 8349× 8349× 8349× 8349× 8349×   8349× 8349× 8349× 8349× 8349× 8349× 8349× 8349× 8349× 8349× 8349×   8349×   50094×   8349× 8115× 8115×   234× 234× 234× 234×           230× 230× 230×     8349× 8349× 8349×   8349× 8349× 8349× 8349× 6307×     2042×   8349×       8349×   2262× 2262× 46×     2216× 2216× 1433× 1433×   2216×                         1390× 1390× 1390× 1390× 1390×       1390×   1390× 1390× 1390×         1390× 1390× 1390× 1390× 1390×     1390× 1390× 1390×   1390× 1390× 1390×   1390× 1390× 1390×   1390×       1390× 1390×     10×   10× 10× 10× 10×         1710× 1710× 1798× 1798× 4582× 4582× 4583× 4583× 24412× 24412× 4428×           1710×   4428× 4428×   197× 197× 197× 197× 197×       197× 197× 197× 197× 197× 197× 197× 197× 197× 197× 88×   197× 197× 197× 427× 427× 193× 193×   234× 234×     197× 197× 193× 193× 193× 193× 427× 427× 427× 427× 193× 193×   427× 427× 427× 427× 427× 427× 2280× 2280× 2280× 1102×   2280× 1102×   2280× 1001× 1001× 1001×     1279×     2280× 2117× 2117×     163× 163×   2280× 2280× 2280× 14×     427× 427× 427× 427×   427× 427× 24×     427× 41×       193×     193× 321× 321× 87×   234× 1279× 1279×       88× 88× 88× 88× 193× 193× 193× 193× 193× 193× 87×   193× 1001× 470×   1001× 909×     92×         88×   1471× 1471× 1471× 1471× 1471× 1471× 264×       1664× 1664× 1664× 1664× 1664× 9806× 9806× 24×     9782× 9782×     1664×   8552× 8552×   1044× 1044× 1044× 6501×   1044×   1471× 1471× 1471× 8781×   1471×   1471× 1471× 1471× 1471× 914× 914× 914×     557× 557× 557× 557× 557×   1471×   1471× 1471× 1485× 1485× 1513× 1513×       1513× 1513× 1513× 4001× 4001× 1097× 1097× 80× 40× 40×     40×       1017× 427× 427× 427×     590×         2904× 2904×     1513× 4001× 4001×     21369× 21369× 21369× 7181× 7181×     14188× 14188×   21369× 21369× 21369× 21369×   8286×         8286×   1471× 1471× 1471× 1471× 1471× 1471× 1471× 1471× 1471× 1471× 1471× 557×   914× 914× 914× 914×   914×                                                                                                                
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* istanbul ignore next */ 
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../../common/utils/helper", "../../common/utils/helper", "@syncfusion/ej2-svg-base", "../../common/model/base", "@syncfusion/ej2-data", "../../common/model/constants", "../../common/utils/helper", "../model/chart3d-Interface", "../utils/chart3dRender"], function (require, exports, ej2_base_1, ej2_base_2, helper_1, helper_2, ej2_svg_base_1, base_1, ej2_data_1, constants_1, helper_3, chart3d_Interface_1, chart3dRender_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Chart3DDataLabelSettings = (function (_super) {
        __extends(Chart3DDataLabelSettings, _super);
        function Chart3DDataLabelSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(false)
        ], Chart3DDataLabelSettings.prototype, "visible", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DDataLabelSettings.prototype, "name", void 0);
        __decorate([
            ej2_base_1.Property('transparent')
        ], Chart3DDataLabelSettings.prototype, "fill", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DDataLabelSettings.prototype, "format", void 0);
        __decorate([
            ej2_base_1.Property(1)
        ], Chart3DDataLabelSettings.prototype, "opacity", void 0);
        __decorate([
            ej2_base_1.Property(0)
        ], Chart3DDataLabelSettings.prototype, "angle", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], Chart3DDataLabelSettings.prototype, "enableRotation", void 0);
        __decorate([
            ej2_base_1.Property('Middle')
        ], Chart3DDataLabelSettings.prototype, "position", void 0);
        __decorate([
            ej2_base_1.Complex({ width: null, color: null }, base_1.Border)
        ], Chart3DDataLabelSettings.prototype, "border", void 0);
        __decorate([
            ej2_base_1.Complex({ left: 5, right: 5, top: 5, bottom: 5 }, base_1.Margin)
        ], Chart3DDataLabelSettings.prototype, "margin", void 0);
        __decorate([
            ej2_base_1.Complex({ size: null, color: null, fontStyle: null, fontWeight: null, fontFamily: null }, chart3d_Interface_1.Chart3DTextFont)
        ], Chart3DDataLabelSettings.prototype, "font", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DDataLabelSettings.prototype, "template", void 0);
        return Chart3DDataLabelSettings;
    }(ej2_base_1.ChildProperty));
    exports.Chart3DDataLabelSettings = Chart3DDataLabelSettings;
    var Chart3DEmptyPointSettings = (function (_super) {
        __extends(Chart3DEmptyPointSettings, _super);
        function Chart3DEmptyPointSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DEmptyPointSettings.prototype, "fill", void 0);
        __decorate([
            ej2_base_1.Property('Gap')
        ], Chart3DEmptyPointSettings.prototype, "mode", void 0);
        return Chart3DEmptyPointSettings;
    }(ej2_base_1.ChildProperty));
    exports.Chart3DEmptyPointSettings = Chart3DEmptyPointSettings;
    var Chart3DPoint = (function () {
        function Chart3DPoint() {
            this.symbolLocations = null;
            this.percentage = null;
            this.isSelect = false;
        }
        return Chart3DPoint;
    }());
    exports.Chart3DPoint = Chart3DPoint;
    var Chart3DSeries = (function (_super) {
        __extends(Chart3DSeries, _super);
        function Chart3DSeries(parent, propName, defaultValue, isArray) {
            var _this = _super.call(this, parent, propName, defaultValue, isArray) || this;
            _this.currentViewData = [];
            _this.clipRect = new ej2_svg_base_1.Rect(0, 0, 0, 0);
            _this.visibleSeriesCount = 0;
            _this.category = 'Series';
            _this.isRectSeries = false;
            _this.all = false;
            return _this;
        }
        Chart3DSeries.prototype.processJsonData = function () {
            var i = 0;
            var point = new Chart3DPoint();
            var xName = this.xName;
            var textMappingName = this instanceof Chart3DSeries && this.dataLabel.name ?
                this.dataLabel.name : '';
            var len = (this.currentViewData || []).length;
            this.points = [];
            this.xMin = Infinity;
            this.xMax = -Infinity;
            this.yMin = Infinity;
            this.yMax = -Infinity;
            this.sizeMax = -Infinity;
            if (this.xAxis.valueType === 'Category') {
                while (i < len) {
                    point = this.dataPoint(i, textMappingName, xName);
                    this.pushCategoryData(point, i, point.x);
                    this.pushData(point, i);
                    this.setEmptyPoint(point, i);
                    i++;
                }
            }
            else if (this.xAxis.valueType.indexOf('DateTime') > -1) {
                var option = {
                    skeleton: 'full',
                    type: 'dateTime'
                };
                var dateParser = this.chart.intl.getDateParser(option);
                var dateFormatter = this.chart.intl.getDateFormat(option);
                while (i < len) {
                    point = this.dataPoint(i, textMappingName, xName);
                    Eif (!ej2_base_2.isNullOrUndefined(point.x) && point.x !== '') {
                        point.x = new Date(ej2_data_1.DataUtil.parse.parseJson({ val: point.x }).val);
                        if (this.xAxis.valueType === 'DateTime') {
                            point.xValue = Date.parse(point.x.toString());
                        }
                        else {
                            this.pushCategoryData(point, i, Date.parse(dateParser(dateFormatter(point.x))).toString());
                        }
                        this.pushData(point, i);
                        this.setEmptyPoint(point, i);
                    }
                    else {
                        point.visible = false;
                    }
                    i++;
                }
            }
            else {
                while (i < len) {
                    point = this.dataPoint(i, textMappingName, xName);
                    point.xValue = point.x;
                    this.pushData(point, i);
                    this.setEmptyPoint(point, i);
                    i++;
                }
            }
        };
        Chart3DSeries.prototype.pushData = function (point, i) {
            point.index = i;
            point.yValue = point.y;
            point.series = this;
            this.xMin = Math.min(this.xMin, point.xValue);
            this.xMax = Math.max(this.xMax, point.xValue);
            this.xData.push(point.xValue);
        };
        Chart3DSeries.prototype.dataPoint = function (i, textMappingName, xName) {
            this.points[i] = new Chart3DPoint();
            var point = this.points[i];
            var currentViewData = this.currentViewData[i];
            var getObjectValueByMappingString = this.get3DObjectValue;
            point.x = getObjectValueByMappingString(xName, currentViewData);
            point.interior = getObjectValueByMappingString(this.pointColorMapping, currentViewData);
            Eif (this instanceof Chart3DSeries) {
                point.y = getObjectValueByMappingString(this.yName, currentViewData);
                point.size = getObjectValueByMappingString(this.size, currentViewData);
                point.text = getObjectValueByMappingString(textMappingName, currentViewData);
                point.tooltip = getObjectValueByMappingString(this.tooltipMappingName, currentViewData);
            }
            return point;
        };
        Chart3DSeries.prototype.get3DObjectValue = function (mappingName, data) {
            return data[mappingName];
        };
        Chart3DSeries.prototype.setEmptyPoint = function (point, i) {
            if (!this.findVisibility(point)) {
                point.visible = true;
                return null;
            }
            point.isEmpty = true;
            var series = this instanceof Chart3DSeries && this;
            var mode = series.emptyPointSettings.mode;
            switch (mode) {
                case 'Zero':
                    point.visible = true;
                    point.y = point.yValue = this.yData[i] = 0;
                    break;
                case 'Average':
                    Eif (this instanceof Chart3DSeries) {
                        point.y = point.yValue = this.yData[i] = this.getAverage(this.yName, i);
                    }
                    point.visible = true;
                    break;
                case 'Drop':
                case 'Gap':
                    this.yData[i] = null;
                    point.visible = false;
                    break;
            }
        };
        Chart3DSeries.prototype.findVisibility = function (point) {
            this.setXYMinMax(point.yValue);
            this.yData.push(point.yValue);
            return ej2_base_2.isNullOrUndefined(point.x) || (ej2_base_2.isNullOrUndefined(point.y) || isNaN(+point.y));
        };
        Chart3DSeries.prototype.setXYMinMax = function (yValue) {
            var isLogAxis = (this.yAxis.valueType === 'Logarithmic' || this.xAxis.valueType === 'Logarithmic');
            var isNegativeValue = yValue < 0 || this.yAxis.rangePadding === 'None';
            var seriesMinY;
            if (!helper_3.setRange(this.yAxis)) {
                seriesMinY = ((isLogAxis ? (yValue) : isNegativeValue ? yValue : 0));
            }
            else {
                seriesMinY = yValue;
            }
            this.yMin = isLogAxis ?
                Math.min(this.yMin, (ej2_base_2.isNullOrUndefined(seriesMinY) || isNaN(seriesMinY) || (seriesMinY === 0) ||
                    (seriesMinY.toString() === '0') || (seriesMinY.toString() === '')) ? this.yMin : seriesMinY) :
                Math.min(this.yMin, (ej2_base_2.isNullOrUndefined(seriesMinY) || isNaN(seriesMinY)) ? this.yMin : seriesMinY);
            this.yMax = Math.max(this.yMax, (ej2_base_2.isNullOrUndefined(yValue) || isNaN(yValue)) ? this.yMax : yValue);
        };
        Chart3DSeries.prototype.pushCategoryData = function (point, index, pointX) {
            Eif (this.chart.tooltip) {
                if (!this.visible) {
                    return null;
                }
            }
            Eif (!this.xAxis.isIndexed) {
                if (this.xAxis.indexLabels[pointX] === undefined) {
                    this.xAxis.indexLabels[pointX] = this.xAxis.labels.length;
                    this.xAxis.labels.push(pointX);
                }
                point.xValue = this.xAxis.indexLabels[pointX];
            }
            else {
                if (this.xAxis.labels[index]) {
                    this.xAxis.labels[index] += ', ' + pointX;
                }
                else {
                    this.xAxis.labels.push(pointX);
                }
                point.xValue = index;
            }
        };
        Chart3DSeries.prototype.getAverage = function (member, i, data) {
            Eif (data === void 0) { data = this.currentViewData; }
            var previous = data[i - 1] ? (data[i - 1][member] || 0) : 0;
            var next = data[i + 1] ? (data[i + 1][member] || 0) : 0;
            return (previous + next) / 2;
        };
        Chart3DSeries.prototype.refreshDataManager = function (chart) {
            var _this = this;
            this.chart = chart;
            var dataSource;
            var isAngular = 'isAngular';
            Iif (chart[isAngular]) {
                dataSource = Object.keys(this.dataSource).length ? this.dataSource : chart.dataSource;
            }
            else {
                dataSource = this.dataSource || chart.dataSource;
            }
            Eif (!(dataSource instanceof ej2_data_1.DataManager) && ej2_base_2.isNullOrUndefined(this.query)) {
                this.dataManagerSuccess({ result: dataSource, count: dataSource.length }, false);
                return;
            }
            var dataManager = this.dataModule.getData(this.dataModule.generateQuery().requiresCount());
            dataManager.then(function (e) { return _this.dataManagerSuccess(e); });
        };
        Chart3DSeries.prototype.dataManagerSuccess = function (e, isRemoteData) {
            Iif (isRemoteData === void 0) { isRemoteData = true; }
            this.currentViewData = e.count ? e.result : [];
            this.chart.allowServerDataBinding = false;
            Eif (this instanceof Chart3DSeries) {
                var argsData = {
                    series: this, data: this.currentViewData, fill: this.interior
                };
                this.chart.trigger(constants_1.seriesRender, argsData);
                this.interior = argsData.fill;
                this.currentViewData = argsData.data;
            }
            this.processJsonData();
            this.refreshChart(isRemoteData);
            this.currentViewData = null;
        };
        Chart3DSeries.prototype.refreshChart = function (isRemoteData) {
            var chart = this.chart;
            Eif (this instanceof Chart3DSeries) {
                chart.visibleSeriesCount += isRemoteData ? 1 : 0;
            }
            Iif (chart.visibleSeries.length === (chart.visibleSeriesCount)) {
                chart.refreshBound();
                chart.trigger('loaded', { chart: chart });
            }
            Eif (this instanceof Chart3DSeries) {
                chart.visibleSeriesCount += isRemoteData ? 0 : 1;
            }
        };
        Chart3DSeries.prototype.refreshAxisLabel = function () {
            if (this.xAxis.valueType !== 'Category') {
                return null;
            }
            this.xAxis.labels = [];
            this.xAxis.indexLabels = {};
            for (var _i = 0, _a = this.xAxis.series; _i < _a.length; _i++) {
                var item = _a[_i];
                if (item.visible) {
                    item.xMin = Infinity;
                    item.xMax = -Infinity;
                    for (var _b = 0, _c = item.points; _b < _c.length; _b++) {
                        var point = _c[_b];
                        item.pushCategoryData(point, point.index, point.x);
                        item.xMin = Math.min(item.xMin, point.xValue);
                        item.xMax = Math.max(item.xMax, point.xValue);
                    }
                }
            }
        };
        Chart3DSeries.prototype.findSeriesCollection = function (column, row, isStack) {
            var seriesCollection = [];
            for (var _i = 0, _a = row.axes; _i < _a.length; _i++) {
                var rowAxis = _a[_i];
                for (var _b = 0, _c = rowAxis.series; _b < _c.length; _b++) {
                    var rowSeries = _c[_b];
                    for (var _d = 0, _e = column.axes; _d < _e.length; _d++) {
                        var axis = _e[_d];
                        for (var _f = 0, _g = axis.series; _f < _g.length; _f++) {
                            var series = _g[_f];
                            if (series === rowSeries && series.visible && this.rectSeriesInChart(series, isStack)) {
                                seriesCollection.push(series);
                            }
                        }
                    }
                }
            }
            return seriesCollection;
        };
        Chart3DSeries.prototype.rectSeriesInChart = function (series, isStack) {
            var type = (series.type).toLowerCase();
            return type.indexOf('column') !== -1 || type.indexOf('bar') !== -1 || isStack;
        };
        Chart3DSeries.prototype.calculateStackedValue = function (isStacking100, chart) {
            for (var _i = 0, _a = chart.columns; _i < _a.length; _i++) {
                var columnItem = _a[_i];
                for (var _b = 0, _c = chart.rows; _b < _c.length; _b++) {
                    var item = _c[_b];
                    this.calculateStackingValues(this.findSeriesCollection(columnItem, item, true), isStacking100);
                }
            }
        };
        Chart3DSeries.prototype.calculateStackingValues = function (seriesCollection, isStacking100) {
            var startValues;
            var endValues;
            var yValues = [];
            var lastPositive = [];
            var lastNegative = [];
            var stackingGroup;
            var lastValue;
            var value;
            var frequencies = [];
            if (isStacking100) {
                frequencies = this.findFrequencies(seriesCollection);
            }
            var groupingValues = [];
            var visiblePoints = [];
            for (var i = 0; i < seriesCollection.length; i++) {
                var series = seriesCollection[i];
                if (!groupingValues[series.stackingGroup]) {
                    groupingValues[series.stackingGroup] = [];
                    groupingValues[series.stackingGroup].push(series);
                }
                else Eif (groupingValues[series.stackingGroup] !== undefined) {
                    groupingValues[series.stackingGroup].push(series);
                }
            }
            var keys = Object.keys(groupingValues);
            for (var k = 0; k < keys.length; k++) {
                var stackingSeies = [];
                var stackedValues = [];
                var seriesCollection_2 = groupingValues[keys[k]];
                for (var _i = 0, seriesCollection_1 = seriesCollection_2; _i < seriesCollection_1.length; _i++) {
                    var series = seriesCollection_1[_i];
                    Eif (series.type.indexOf('Stacking') !== -1) {
                        stackingGroup = series.stackingGroup;
                        if (!lastPositive[stackingGroup]) {
                            lastPositive[stackingGroup] = [];
                            lastNegative[stackingGroup] = [];
                        }
                        yValues = series.yData;
                        startValues = [];
                        endValues = [];
                        stackingSeies.push(series);
                        visiblePoints = helper_1.getVisiblePoints(series);
                        for (var j = 0, pointsLength = visiblePoints.length; j < pointsLength; j++) {
                            lastValue = 0;
                            value = +yValues[j];
                            if (lastPositive[stackingGroup][visiblePoints[j].xValue] === undefined) {
                                lastPositive[stackingGroup][visiblePoints[j].xValue] = 0;
                            }
                            if (lastNegative[stackingGroup][visiblePoints[j].xValue] === undefined) {
                                lastNegative[stackingGroup][visiblePoints[j].xValue] = 0;
                            }
                            if (isStacking100) {
                                value = value / frequencies[stackingGroup][visiblePoints[j].xValue] * 100;
                                value = !isNaN(value) ? value : 0;
                                visiblePoints[j].percentage = +(value.toFixed(2));
                            }
                            else {
                                stackedValues[j] = stackedValues[j] ?
                                    stackedValues[j] + Math.abs(value) : Math.abs(value);
                            }
                            if (value >= 0) {
                                lastValue = lastPositive[stackingGroup][visiblePoints[j].xValue];
                                lastPositive[stackingGroup][visiblePoints[j].xValue] += value;
                            }
                            else {
                                lastValue = lastNegative[stackingGroup][visiblePoints[j].xValue];
                                lastNegative[stackingGroup][visiblePoints[j].xValue] += value;
                            }
                            startValues.push(lastValue);
                            endValues.push(value + lastValue);
                            if (isStacking100 && (endValues[j] > 100)) {
                                endValues[j] = 100;
                            }
                        }
                        series.stackedValues = new helper_1.StackValues(startValues, endValues);
                        var isLogAxis = series.yAxis.valueType === 'Logarithmic';
                        var isColumnBarType = (series.type.indexOf('Column') !== -1 || series.type.indexOf('Bar') !== -1);
                        series.yMin = isLogAxis && isColumnBarType && series.yMin < 1 ? series.yMin :
                            Math.min.apply(0, isStacking100 ? startValues : endValues);
                        series.yMax = Math.max.apply(0, endValues);
                        if (series.yMin > Math.min.apply(0, endValues)) {
                            series.yMin = (isStacking100) ? -100 :
                                isLogAxis && isColumnBarType && series.yMin < 1 ? series.yMin : Math.min.apply(0, endValues);
                        }
                        if (series.yMax < Math.max.apply(0, startValues)) {
                            series.yMax = 0;
                        }
                    }
                }
                this.findPercentageOfStacking(stackingSeies, stackedValues, isStacking100);
            }
        };
        Chart3DSeries.prototype.findPercentageOfStacking = function (stackingSeries, values, isStacking100) {
            for (var _i = 0, stackingSeries_1 = stackingSeries; _i < stackingSeries_1.length; _i++) {
                var item = stackingSeries_1[_i];
                if (isStacking100) {
                    return null;
                }
                for (var _a = 0, _b = helper_1.getVisiblePoints(item); _a < _b.length; _a++) {
                    var point = _b[_a];
                    point.percentage = Math.abs(+(point.y / values[point.index] * 100).toFixed(2));
                }
            }
        };
        Chart3DSeries.prototype.findFrequencies = function (seriesCollection) {
            var frequencies = [];
            var stackingGroup;
            var visiblePoints = [];
            for (var _i = 0, seriesCollection_3 = seriesCollection; _i < seriesCollection_3.length; _i++) {
                var series = seriesCollection_3[_i];
                series.yAxis.isStack100 = series.type.indexOf('100') !== -1 ? true : false;
                visiblePoints = this.getVisiblePoints();
                Eif (series.type.indexOf('Stacking') !== -1) {
                    stackingGroup = series.stackingGroup;
                    if (!frequencies[stackingGroup]) {
                        frequencies[stackingGroup] = [];
                    }
                    for (var j = 0, pointsLength = visiblePoints.length; j < pointsLength; j++) {
                        if (frequencies[stackingGroup][visiblePoints[j].xValue] === undefined) {
                            frequencies[stackingGroup][visiblePoints[j].xValue] = 0;
                        }
                        if (series.yData[j] > 0) {
                            frequencies[stackingGroup][visiblePoints[j].xValue] += series.yData[j];
                        }
                        else {
                            frequencies[stackingGroup][visiblePoints[j].xValue] -= series.yData[j];
                        }
                    }
                }
            }
            return frequencies;
        };
        Chart3DSeries.prototype.renderSeries = function (chart) {
            var seriesType = helper_2.firstToLowerCase(this.type);
            seriesType = seriesType.replace('100', '');
            Eif (chart[seriesType + 'Series3DModule']) {
                this.visiblePoints = this.getVisiblePoints();
                chart[seriesType + 'Series3DModule'].draw(this, chart);
                if (this.dataLabel.visible && this.visible) {
                    chart.dataLabel3DModule.render(this, this.chart, this.dataLabel);
                }
            }
        };
        Chart3DSeries.prototype.getVisiblePoints = function () {
            var points = ej2_base_2.extend([], this.points, null, true);
            var tempPoints = [];
            var tempPoint;
            var pointIndex = 0;
            for (var i = 0; i < points.length; i++) {
                tempPoint = points[i];
                if (ej2_base_2.isNullOrUndefined(tempPoint.x)) {
                    continue;
                }
                else {
                    tempPoint.index = pointIndex++;
                    tempPoints.push(tempPoint);
                }
            }
            return tempPoints;
        };
        Chart3DSeries.prototype.setPointColor = function (point, color) {
            color = point.interior || color;
            return point.isEmpty ? (this.emptyPointSettings.fill || color) : color;
        };
        Chart3DSeries.prototype.getYValues = function (points) {
            var values = [];
            var length = points.length;
            for (var i = 0; i < length; i++) {
                values.push(points[i].yValue);
            }
            return values;
        };
        Chart3DSeries.prototype.getXValues = function (points) {
            var values = [];
            var length = points.length;
            for (var i = 0; i < length; i++) {
                values.push(points[i].xValue);
            }
            return values;
        };
        Chart3DSeries.prototype.getSegmentDepth = function (series) {
            var actualDepth = this.chart.depth;
            var start;
            var end;
            if (this.chart.enableSideBySidePlacement) {
                var space = actualDepth / 4;
                start = space;
                end = space * (series.columnFacet === 'Rectangle' ? 2.5 : 3);
            }
            else {
                var index = series.position - 1;
                var count = series.rectCount;
                var space = actualDepth / ((count * 2) + count + 1);
                start = space + (space * index * 3);
                end = start + space * (series.columnFacet === 'Rectangle' ? 1.5 : 2);
            }
            return { start: start, end: end, delta: end - start };
        };
        Chart3DSeries.prototype.getSideBySidePositions = function (series) {
            var chart = series.chart;
            for (var _i = 0, _a = chart.columns; _i < _a.length; _i++) {
                var columnItem = _a[_i];
                for (var _b = 0, _c = chart.rows; _b < _c.length; _b++) {
                    var item = _c[_b];
                    this.findRectPosition(series.findSeriesCollection(columnItem, item, false));
                }
            }
        };
        Chart3DSeries.prototype.findRectPosition = function (seriesCollection) {
            var groupingValues = [];
            var vSeries = { rectCount: 0, position: null };
            for (var i = 0; i < seriesCollection.length; i++) {
                var value = seriesCollection[i];
                if (value.type.indexOf('Stacking') !== -1 || value.groupName !== '') {
                    var groupName = value.type.indexOf('Stacking') !== -1 ? value.stackingGroup : value.type + value.groupName;
                    if (groupName) {
                        if (groupingValues[groupName] === undefined) {
                            value.position = vSeries.rectCount;
                            groupingValues[groupName] = vSeries.rectCount++;
                        }
                        else {
                            value.position = groupingValues[groupName];
                        }
                    }
                    else {
                        if (vSeries.position === null) {
                            vSeries.rectCount++;
                            value.position = vSeries.rectCount;
                            vSeries.position = vSeries.rectCount;
                        }
                        else {
                            value.position = vSeries.position;
                        }
                    }
                }
                else {
                    vSeries.rectCount++;
                    value.position = vSeries.rectCount;
                }
            }
            for (var i = 0; i < seriesCollection.length; i++) {
                var value = seriesCollection[i];
                value.rectCount = vSeries.rectCount;
            }
        };
        Chart3DSeries.prototype.getDoubleRange = function (start, end) {
            var mstart;
            var mend;
            if (start > end) {
                mstart = end;
                mend = start;
            }
            else {
                mstart = start;
                mend = end;
            }
            var mdelta = mend - mstart;
            var mmedian = (mstart + mend) / 2;
            var misEmpty = isNaN(mstart) || isNaN(mend);
            return { start: mstart, end: mend, delta: mdelta, median: mmedian, isEmpty: misEmpty };
        };
        Chart3DSeries.prototype.setStyle = function (series) {
            var options = {
                interior: series.interior,
                opacity: series.opacity,
                dashArray: ''
            };
            return options;
        };
        Chart3DSeries.prototype.getSideBySideInfo = function (series) {
            this.chart.currentSeries = series;
            var minimumPointDelta = chart3dRender_1.getMinPointsDeltaValue(series.xAxis, this.chart.visibleSeries);
            var spacing = series.columnSpacing;
            var columnWidth = (series.columnWidth === null || isNaN(+series.columnWidth)) ? 0.7 : Math.min(series.columnWidth, 1);
            this.getSideBySidePositions(series);
            var pos = series.position;
            var all = series.rectCount;
            var width = minimumPointDelta * columnWidth;
            var loc = (pos - (series.stackingGroup === '' ? 1 : 0)) / all - 0.5;
            var range = this.getDoubleRange(loc, loc + (1 / all));
            if (!this.chart.enableSideBySidePlacement) {
                return this.getDoubleRange(-width / 2, width / 2);
            }
            Eif (!range.isEmpty) {
                range = this.getDoubleRange(range.start * width, range.end * width);
                var radius = spacing * range.delta;
                range = this.getDoubleRange(range.start + radius / 2, range.end - radius / 2);
            }
            return range;
        };
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "xName", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "pointColorMapping", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], Chart3DSeries.prototype, "visible", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DSeries.prototype, "xAxisName", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DSeries.prototype, "yAxisName", void 0);
        __decorate([
            ej2_base_1.Complex({ duration: 2000 }, base_1.Animation)
        ], Chart3DSeries.prototype, "animation", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DSeries.prototype, "fill", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "dataSource", void 0);
        __decorate([
            ej2_base_1.Property()
        ], Chart3DSeries.prototype, "query", void 0);
        __decorate([
            ej2_base_1.Complex({}, Chart3DDataLabelSettings)
        ], Chart3DSeries.prototype, "dataLabel", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "name", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "yName", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "size", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "stackingGroup", void 0);
        __decorate([
            ej2_base_1.Property(1)
        ], Chart3DSeries.prototype, "opacity", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "groupName", void 0);
        __decorate([
            ej2_base_1.Property('Column')
        ], Chart3DSeries.prototype, "type", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], Chart3DSeries.prototype, "enableTooltip", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "tooltipFormat", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "tooltipMappingName", void 0);
        __decorate([
            ej2_base_1.Property('SeriesType')
        ], Chart3DSeries.prototype, "legendShape", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Chart3DSeries.prototype, "legendImageUrl", void 0);
        __decorate([
            ej2_base_1.Complex(null, Chart3DEmptyPointSettings)
        ], Chart3DSeries.prototype, "emptyPointSettings", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], Chart3DSeries.prototype, "columnWidth", void 0);
        __decorate([
            ej2_base_1.Property('Rectangle')
        ], Chart3DSeries.prototype, "columnFacet", void 0);
        __decorate([
            ej2_base_1.Property(0.1)
        ], Chart3DSeries.prototype, "columnSpacing", void 0);
        return Chart3DSeries;
    }(ej2_base_1.ChildProperty));
    exports.Chart3DSeries = Chart3DSeries;
});