all files / accumulation-chart/model/ acc-base.js

94.41% Statements 439/465
85.52% Branches 254/297
97.73% Functions 43/44
94.71% Lines 430/454
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              42×                                     40×                                                                         27×             4074× 4074× 4074× 4074× 4074× 4074× 4074× 4074× 4074× 4074× 4074× 4074×     79× 79× 79× 79× 79× 79× 79× 79× 79× 79×   482× 482× 482× 482× 482× 482× 482×         482× 482×     482× 482× 482× 482×   482×   473× 473×     483× 483× 483× 10× 10×   473× 473× 473× 473× 473× 473× 473× 473× 4041× 4041× 3954× 29×   3954×     87× 87× 87× 87×     473× 473× 25× 25× 25× 25× 80× 80×     473×       26× 26× 26× 26× 26× 26× 26×   3986× 3986× 3986× 3986×   4041× 351× 66× 66×   285× 21× 21×     3954×   483× 483× 4154×   4110×       4048× 4048× 4048× 4048× 4048× 4048× 4048× 4048× 4048× 4048× 4048× 4048×   531×   531× 531× 531× 313× 313×   313×   531× 422× 400×   422×   531× 422× 422× 422× 422×     541× 541× 541× 541× 541× 4418× 4418× 4418×         4418× 4418× 4418× 4418× 42× 42×   4418× 4418×     541×   323× 323×     323× 323× 323× 323× 323× 2623× 2623× 2608×   2608×     2623× 1022×     1601× 1013×     588×       361× 726× 829× 323× 323× 323× 17× 17×     17×   323×   9833× 9833× 9833× 9833×   76× 76× 41×       4048× 4004×   44× 44×         29× 29×         15× 12× 12× 12×                                                                 83× 76×         33× 30×     30× 30× 30×         10× 10× 10× 10× 10×       30×     10× 10× 10× 10×                 10× 10× 10×   10×   10× 10× 10×   10× 10×     10×     4418×                                                                                                                                                                     199× 1049× 1049× 199×            
/* 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", "@syncfusion/ej2-data", "../../common/model/base", "@syncfusion/ej2-svg-base", "../../common/utils/helper", "../../common/model/constants", "../../common/model/theme", "../../common/utils/helper", "../../common/user-interaction/selection", "../../common/legend/legend"], function (require, exports, ej2_base_1, ej2_base_2, ej2_data_1, base_1, ej2_svg_base_1, helper_1, constants_1, theme_1, helper_2, selection_1, legend_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AccumulationAnnotationSettings = (function (_super) {
        __extends(AccumulationAnnotationSettings, _super);
        function AccumulationAnnotationSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationAnnotationSettings.prototype, "content", void 0);
        __decorate([
            ej2_base_1.Property('0')
        ], AccumulationAnnotationSettings.prototype, "x", void 0);
        __decorate([
            ej2_base_1.Property('0')
        ], AccumulationAnnotationSettings.prototype, "y", void 0);
        __decorate([
            ej2_base_1.Property('Pixel')
        ], AccumulationAnnotationSettings.prototype, "coordinateUnits", void 0);
        __decorate([
            ej2_base_1.Property('Chart')
        ], AccumulationAnnotationSettings.prototype, "region", void 0);
        __decorate([
            ej2_base_1.Property('Middle')
        ], AccumulationAnnotationSettings.prototype, "verticalAlignment", void 0);
        __decorate([
            ej2_base_1.Property('Center')
        ], AccumulationAnnotationSettings.prototype, "horizontalAlignment", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationAnnotationSettings.prototype, "description", void 0);
        return AccumulationAnnotationSettings;
    }(ej2_base_1.ChildProperty));
    exports.AccumulationAnnotationSettings = AccumulationAnnotationSettings;
    var AccumulationDataLabelSettings = (function (_super) {
        __extends(AccumulationDataLabelSettings, _super);
        function AccumulationDataLabelSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(false)
        ], AccumulationDataLabelSettings.prototype, "visible", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], AccumulationDataLabelSettings.prototype, "showZero", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationDataLabelSettings.prototype, "name", void 0);
        __decorate([
            ej2_base_1.Property('transparent')
        ], AccumulationDataLabelSettings.prototype, "fill", void 0);
        __decorate([
            ej2_base_1.Property('Inside')
        ], AccumulationDataLabelSettings.prototype, "position", void 0);
        __decorate([
            ej2_base_1.Property(5)
        ], AccumulationDataLabelSettings.prototype, "rx", void 0);
        __decorate([
            ej2_base_1.Property(5)
        ], AccumulationDataLabelSettings.prototype, "ry", void 0);
        __decorate([
            ej2_base_1.Property(0)
        ], AccumulationDataLabelSettings.prototype, "angle", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], AccumulationDataLabelSettings.prototype, "enableRotation", void 0);
        __decorate([
            ej2_base_1.Complex({ width: null, color: null }, base_1.Border)
        ], AccumulationDataLabelSettings.prototype, "border", void 0);
        __decorate([
            ej2_base_1.Complex({ fontFamily: null, size: null, fontStyle: null, fontWeight: null, color: null }, base_1.Font)
        ], AccumulationDataLabelSettings.prototype, "font", void 0);
        __decorate([
            ej2_base_1.Complex({}, base_1.Connector)
        ], AccumulationDataLabelSettings.prototype, "connectorStyle", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationDataLabelSettings.prototype, "template", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationDataLabelSettings.prototype, "format", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationDataLabelSettings.prototype, "maxWidth", void 0);
        __decorate([
            ej2_base_1.Property('Ellipsis')
        ], AccumulationDataLabelSettings.prototype, "textOverflow", void 0);
        __decorate([
            ej2_base_1.Property('Normal')
        ], AccumulationDataLabelSettings.prototype, "textWrap", void 0);
        return AccumulationDataLabelSettings;
    }(ej2_base_1.ChildProperty));
    exports.AccumulationDataLabelSettings = AccumulationDataLabelSettings;
    var PieCenter = (function (_super) {
        __extends(PieCenter, _super);
        function PieCenter() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property('50%')
        ], PieCenter.prototype, "x", void 0);
        __decorate([
            ej2_base_1.Property('50%')
        ], PieCenter.prototype, "y", void 0);
        return PieCenter;
    }(ej2_base_1.ChildProperty));
    exports.PieCenter = PieCenter;
    var AccPoints = (function () {
        function AccPoints() {
            this.visible = true;
            this.symbolLocation = null;
            this.region = null;
            this.labelRegion = null;
            this.labelVisible = true;
            this.regions = null;
            this.isExplode = false;
            this.isClubbed = false;
            this.isSliced = false;
            this.argsData = null;
            this.isLabelUpdated = null;
            this.initialLabelRegion = null;
        }
        return AccPoints;
    }());
    exports.AccPoints = AccPoints;
    var AccumulationSeries = (function (_super) {
        __extends(AccumulationSeries, _super);
        function AccumulationSeries() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.points = [];
            _this.clubbedPoints = [];
            _this.sumOfPoints = 0;
            _this.isRectSeries = true;
            _this.clipRect = new ej2_svg_base_1.Rect(0, 0, 0, 0);
            _this.category = 'Series';
            _this.rightSidePoints = [];
            _this.leftSidePoints = [];
            return _this;
        }
        AccumulationSeries.prototype.refreshDataManager = function (accumulation, render) {
            var _this = this;
            this.accumulation = accumulation;
            this.radius = this.radius ? this.radius : (ej2_base_1.Browser.isDevice && this.dataLabel.position === 'Outside') ? '40%' : '80%';
            var dateSource = this.dataSource || accumulation.dataSource;
            Eif (!(dateSource instanceof ej2_data_1.DataManager) && ej2_base_2.isNullOrUndefined(this.query)) {
                this.dataManagerSuccess({ result: dateSource, count: dateSource.length }, accumulation, render);
                return;
            }
            var dataManager = this.dataModule.getData(this.dataModule.generateQuery().requiresCount());
            dataManager.then(function (e) { return _this.dataManagerSuccess(e, accumulation); });
        };
        AccumulationSeries.prototype.dataManagerSuccess = function (e, accumulation, render) {
            Iif (render === void 0) { render = true; }
            var argsData = {
                name: constants_1.seriesRender, series: this, data: e.result
            };
            accumulation.allowServerDataBinding = false;
            accumulation.trigger(constants_1.seriesRender, argsData);
            this.resultData = e.result !== '' ? e.result : [];
            if (!accumulation.isBlazor && !render) {
                this.getPoints(this.resultData, accumulation);
            }
            if ((++accumulation.seriesCounts === accumulation.visibleSeries.length && render)
                || (window['Blazor'] && !render && accumulation.seriesCounts === 1)) {
                this.getPoints(this.resultData, accumulation);
                accumulation.refreshChart();
            }
        };
        AccumulationSeries.prototype.getPoints = function (result, accumulation) {
            var length = Object.keys(result).length;
            this.sumOfPoints = 0;
            if (length === 0) {
                this.points = [];
                return null;
            }
            this.findSumOfPoints(result);
            this.points = [];
            this.clubbedPoints = [];
            this.sumOfClub = 0;
            var point;
            var colors = this.palettes.length ? this.palettes : theme_1.getSeriesColor(accumulation.theme);
            var clubValue = helper_1.stringToNumber(this.groupTo, this.sumOfPoints);
            for (var i = 0; i < length; i++) {
                point = this.setPoints(result, i, colors, accumulation);
                if (!this.isClub(point, clubValue, i)) {
                    if (ej2_base_2.isNullOrUndefined(point.y)) {
                        point.visible = false;
                    }
                    this.pushPoints(point, colors);
                }
                else {
                    point.index = this.clubbedPoints.length;
                    point.isExplode = true;
                    this.clubbedPoints.push(point);
                    point.isSliced = true;
                }
            }
            this.lastGroupTo = this.groupTo;
            if (this.sumOfClub > 0) {
                var clubPoint_1 = this.generateClubPoint();
                this.pushPoints(clubPoint_1, colors);
                var pointsLength_1 = this.points.length - 1;
                this.clubbedPoints.map(function (point) {
                    point.index += pointsLength_1;
                    point.color = clubPoint_1.color;
                });
            }
            if (this.clubbedPoints.length && this.explode && this.type === 'Pie'
                && (this.explodeAll || this.points[this.points.length - 1].index === this.explodeIndex)) {
                this.points.splice(this.points.length - 1, 1);
                this.points = this.points.concat(this.clubbedPoints);
            }
        };
        AccumulationSeries.prototype.generateClubPoint = function () {
            var clubPoint = new AccPoints();
            clubPoint.isClubbed = true;
            clubPoint.x = 'Others';
            clubPoint.y = this.sumOfClub;
            clubPoint.text = clubPoint.originalText = clubPoint.x + ': ' + this.sumOfClub;
            clubPoint.sliceRadius = '80%';
            return clubPoint;
        };
        AccumulationSeries.prototype.pushPoints = function (point, colors) {
            point.index = this.points.length;
            point.isExplode = this.explodeAll || (point.index === this.explodeIndex);
            point.color = point.color || colors[point.index % colors.length];
            this.points.push(point);
        };
        AccumulationSeries.prototype.isClub = function (point, clubValue, index) {
            if (!ej2_base_2.isNullOrUndefined(clubValue)) {
                if (this.groupMode === 'Value' && Math.abs(point.y) <= clubValue) {
                    this.sumOfClub += Math.abs(point.y);
                    return true;
                }
                else if (this.groupMode === 'Point' && index >= clubValue) {
                    this.sumOfClub += Math.abs(point.y);
                    return true;
                }
            }
            return false;
        };
        AccumulationSeries.prototype.findSumOfPoints = function (result) {
            var length = Object.keys(result).length;
            for (var i = 0; i < length; i++) {
                if (!ej2_base_2.isNullOrUndefined(result[i]) && !ej2_base_2.isNullOrUndefined(result[i][this.yName])
                    && !isNaN(result[i][this.yName])) {
                    this.sumOfPoints += Math.abs(result[i][this.yName]);
                }
            }
        };
        AccumulationSeries.prototype.setPoints = function (data, i, colors, accumulation) {
            var point = new AccPoints();
            point.x = ej2_base_2.getValue(this.xName, data[i]);
            point.y = ej2_base_2.getValue(this.yName, data[i]);
            point.legendImageUrl = ej2_base_2.getValue(this.legendImageUrl, data[i]);
            point.color = ej2_base_2.getValue(this.pointColorMapping, data[i]);
            point.text = point.originalText = ej2_base_2.getValue(this.dataLabel.name || '', data[i]);
            point.tooltip = ej2_base_2.getValue(this.tooltipMappingName || '', data[i]);
            point.sliceRadius = ej2_base_2.getValue(this.radius, data[i]);
            point.sliceRadius = ej2_base_2.isNullOrUndefined(point.sliceRadius) ? '80%' : point.sliceRadius;
            point.separatorY = accumulation.intl.formatNumber(point.y, { useGrouping: accumulation.useGroupingSeparator });
            this.setAccEmptyPoint(point, i, data);
            return point;
        };
        AccumulationSeries.prototype.renderSeries = function (accumulation, redraw) {
            var seriesGroup = redraw ? helper_2.getElement(accumulation.element.id + '_Series_' + this.index) :
                accumulation.renderer.createGroup({ id: accumulation.element.id + '_Series_' + this.index });
            this.renderPoints(accumulation, seriesGroup, redraw);
            var datalabelGroup;
            if (accumulation.accumulationDataLabelModule && this.dataLabel.visible) {
                datalabelGroup = accumulation.renderer.createGroup({ id: accumulation.element.id + '_datalabel_Series_' + this.index });
                datalabelGroup.style.visibility =
                    (((this.animation.enable && ej2_base_1.animationMode !== 'Disable') || ej2_base_1.animationMode === 'Enable') && accumulation.animateSeries && this.type === 'Pie') ? 'hidden' : 'visible';
                this.renderDataLabel(accumulation, datalabelGroup, redraw);
            }
            if (this.type === 'Pie') {
                if (!accumulation.redraw) {
                    this.findMaxBounds(this.labelBound, this.accumulationBound);
                }
                accumulation.pieSeriesModule.animateSeries(accumulation, this.animation, this, seriesGroup, this.borderRadius, this.points);
            }
            if (!accumulation.redraw && accumulation.accumulationLegendModule) {
                this.labelBound.x -= accumulation.explodeDistance;
                this.labelBound.y -= accumulation.explodeDistance;
                this.labelBound.height += (accumulation.explodeDistance - this.labelBound.y);
                this.labelBound.width += (accumulation.explodeDistance - this.labelBound.x);
            }
        };
        AccumulationSeries.prototype.renderPoints = function (accumulation, seriesGroup, redraw, previouRadius, previousCenter, pointAnimation) {
            var pointId = accumulation.element.id + '_Series_' + this.index + '_Point_';
            var option;
            var patternFill;
            var patterns = ['Chessboard', 'Dots', 'DiagonalForward', 'Crosshatch', 'Pacman', 'DiagonalBackward', 'Grid', 'Turquoise', 'Star', 'Triangle', 'Circle', 'Tile', 'HorizontalDash', 'VerticalDash', 'Rectangle', 'Box', 'VerticalStripe', 'HorizontalStripe', 'Bubble'];
            for (var _i = 0, _a = this.points; _i < _a.length; _i++) {
                var point = _a[_i];
                point.percentage = (+(point.y / this.sumOfPoints * 100).toFixed(2));
                var argsData = {
                    cancel: false, name: constants_1.pointRender, series: this, point: point, fill: point.color,
                    border: this.isEmpty(point) ? { width: this.emptyPointSettings.border.width, color: this.emptyPointSettings.border.color } :
                        { width: this.border.width, color: this.border.color }, pattern: this.applyPattern ? patterns[point.index % patterns.length] : 'None'
                };
                accumulation.trigger(constants_1.pointRender, argsData);
                point.color = argsData.fill;
                patternFill = point.color;
                if (this.applyPattern) {
                    var selection = new selection_1.BaseSelection(accumulation);
                    patternFill = selection.pattern(accumulation, point.color, point.index, argsData.pattern, this.opacity);
                }
                option = new ej2_svg_base_1.PathOption(pointId + point.index, patternFill, argsData.border.width || 1, argsData.border.color || point.color, this.opacity, argsData.series.dashArray, '');
                accumulation[(helper_2.firstToLowerCase(this.type) + 'SeriesModule')].
                    renderPoint(point, this, accumulation, option, seriesGroup, redraw, previouRadius, previousCenter, pointAnimation);
            }
            helper_1.appendChildElement(false, accumulation.getSeriesElement(), seriesGroup, redraw);
        };
        AccumulationSeries.prototype.renderDataLabel = function (accumulation, datalabelGroup, redraw) {
            accumulation.accumulationDataLabelModule.findAreaRect();
            var element = ej2_base_1.createElement('div', {
                id: accumulation.element.id + '_Series_0' + '_DataLabelCollections'
            });
            this.leftSidePoints = [];
            this.rightSidePoints = [];
            var firstQuarter = [];
            var secondQuarter = [];
            for (var _i = 0, _a = this.points; _i < _a.length; _i++) {
                var point = _a[_i];
                if (point.visible) {
                    Eif (this.dataLabel.showZero || (!this.dataLabel.showZero && ((point.y !== 0) || (point.y === 0 &&
                        this.emptyPointSettings.mode === 'Zero')))) {
                        accumulation.accumulationDataLabelModule.renderDataLabel(point, this.dataLabel, datalabelGroup, this.points, this.index, element, redraw);
                    }
                }
                if (point.midAngle >= 90 && point.midAngle <= 270) {
                    this.leftSidePoints.push(point);
                }
                else {
                    if (point.midAngle >= 0 && point.midAngle <= 90) {
                        secondQuarter.push(point);
                    }
                    else {
                        firstQuarter.push(point);
                    }
                }
            }
            firstQuarter.sort(function (a, b) { return a.midAngle - b.midAngle; });
            secondQuarter.sort(function (a, b) { return a.midAngle - b.midAngle; });
            this.leftSidePoints.sort(function (a, b) { return a.midAngle - b.midAngle; });
            this.rightSidePoints = firstQuarter.concat(secondQuarter);
            accumulation.accumulationDataLabelModule.drawDataLabels(this, this.dataLabel, datalabelGroup, element, redraw);
            if (this.dataLabel.template !== null && element.childElementCount) {
                var dataLabelCallBack = accumulation.accumulationDataLabelModule.drawDataLabels.bind(accumulation.accumulationDataLabelModule, this, this.dataLabel, datalabelGroup, element, redraw);
                Iif (accumulation.isReact) {
                    accumulation.renderReactTemplates(dataLabelCallBack);
                }
                helper_1.appendChildElement(false, helper_2.getElement(accumulation.element.id + '_Secondary_Element'), element, redraw);
            }
            helper_1.appendChildElement(false, accumulation.getSeriesElement(), datalabelGroup, redraw);
        };
        AccumulationSeries.prototype.findMaxBounds = function (totalbound, bound) {
            totalbound.x = bound.x < totalbound.x ? bound.x : totalbound.x;
            totalbound.y = bound.y < totalbound.y ? bound.y : totalbound.y;
            totalbound.height = (bound.y + bound.height) > totalbound.height ? (bound.y + bound.height) : totalbound.height;
            totalbound.width = (bound.x + bound.width) > totalbound.width ? (bound.x + bound.width) : totalbound.width;
        };
        AccumulationSeries.prototype.findMaxLabelWidth = function () {
            var max;
            for (var i = 0; i < this.points.length; i++) {
                max = this.points[0].textSize.width;
                if (max < this.points[i].textSize.width) {
                    max = this.points[i].textSize.width;
                }
            }
            return max;
        };
        AccumulationSeries.prototype.setAccEmptyPoint = function (point, i, data) {
            if (!(ej2_base_2.isNullOrUndefined(point.y) || isNaN(point.y))) {
                return null;
            }
            point.color = this.emptyPointSettings.fill || point.color;
            switch (this.emptyPointSettings.mode) {
                case 'Zero':
                    point.y = 0;
                    point.visible = true;
                    break;
                case 'Average': {
                    var previous = data[i - 1] ? (data[i - 1][this.yName] || 0) : 0;
                    var next = data[i + 1] ? (data[i + 1][this.yName] || 0) : 0;
                    point.y = (Math.abs(previous) + Math.abs(next)) / 2;
                    this.sumOfPoints += point.y;
                    point.visible = true;
                    break;
                }
                default:
                    point.visible = false;
                    break;
            }
        };
        AccumulationSeries.prototype.setData = function (data, duration) {
            Iif (!data) {
                return null;
            }
            var samePoints = false;
            Eif (this.dataSource.length === data.length) {
                samePoints = true;
                for (var i = 0; i < data.length; i++) {
                    if (this.dataSource[i][this.xName] === data[i][this.xName]) {
                        var point = this.points[i];
                        var existingPoint = this.dataSource[i];
                        Iif ((existingPoint[this.yName] !== data[i][this.yName])) {
                            point.y = data[i][this.yName];
                            this.dataSource[i] = data[i];
                        }
                    }
                    else {
                        samePoints = false;
                        break;
                    }
                }
            }
            Eif (!samePoints) {
                this.dataSource = data;
            }
            else {
                this.sumOfPoints = 0;
                this.findSumOfPoints(this.dataSource);
                this.accumulation.redraw = this.borderRadius ? false : this.accumulation.enableAnimation;
                this.accumulation.animateSeries = false;
                var chartDuration = this.accumulation.duration;
                this.accumulation.duration = ej2_base_2.isNullOrUndefined(duration) ? 500 : duration;
                this.accumulation[(helper_2.firstToLowerCase(this.type) + 'SeriesModule')].initProperties(this.accumulation, this);
                this.renderPoints(this.accumulation, helper_2.getElement(this.accumulation.element.id + '_Series_' + this.index), this.accumulation.redraw);
                if (this.accumulation.centerLabel.text) {
                    this.accumulation.renderCenterLabel(true, true);
                }
                if (this.accumulation.annotationModule) {
                    this.accumulation.annotationModule.renderAnnotations(helper_2.getElement(this.accumulation.element.id + '_Secondary_Element'));
                }
                if (this.accumulation.accumulationDataLabelModule && this.dataLabel.visible) {
                    this.renderDataLabel(this.accumulation, helper_2.getElement(this.accumulation.element.id + '_datalabel_Series_' + this.index), this.accumulation.redraw);
                }
                this.accumulation.redraw = false;
                this.accumulation.duration = chartDuration;
            }
        };
        AccumulationSeries.prototype.addPoint = function (dataPoint, duration) {
            var maxWidth;
            Eif (this.accumulation.series[0].dataLabel.visible) {
                maxWidth = this.findMaxLabelWidth();
            }
            this.dataSource.push(dataPoint);
            this.resultData = this.dataSource;
            this.sumOfPoints = 0;
            var visiblepoints = [];
            for (var i = 0; i < this.resultData.length; i++) {
                if (this.points[i] && this.points[i].visible) {
                    visiblepoints.push(this.resultData[i]);
                }
                else Eif (i === this.resultData.length - 1) {
                    visiblepoints.push(this.resultData[i]);
                }
            }
            this.findSumOfPoints(visiblepoints);
            var pointIndex = this.points.length === 0 ? 0 : this.points[this.points.length - 1].index + 1;
            var colors = this.palettes.length ? this.palettes : theme_1.getSeriesColor(this.accumulation.theme);
            var point = this.setPoints(this.dataSource, pointIndex, colors, this.accumulation);
            this.pushPoints(point, colors);
            this.accumulation.redraw = this.borderRadius ? false : this.accumulation.enableAnimation;
            var chartDuration = this.accumulation.duration;
            this.accumulation.duration = ej2_base_2.isNullOrUndefined(duration) ? 500 : duration;
            this.updateSeries(helper_2.getElement(this.accumulation.element.id + '_Series_' + this.index), maxWidth, 'addPoint');
            this.accumulation.redraw = false;
            this.accumulation.duration = chartDuration;
        };
        AccumulationSeries.prototype.removePoint = function (index, duration) {
            var dataSource = ej2_base_1.extend([], this.dataSource, null, true);
            var chartDuration = this.accumulation.duration;
            Eif (dataSource.length > 0 && index >= 0 && index < dataSource.length) {
                this.sumOfPoints = 0;
                var removepoints = [];
                for (var i = 0; i < this.dataSource.length; i++) {
                    if (i !== index && this.points[i] && this.points[i].visible) {
                        removepoints.push(this.dataSource[i]);
                    }
                }
                dataSource.splice(index, 1);
                this.dataSource.splice(index, 1);
                this.findSumOfPoints(removepoints);
                this.accumulation.redraw = this.borderRadius ? false : this.accumulation.enableAnimation;
                this.accumulation.duration = ej2_base_2.isNullOrUndefined(duration) ? 500 : duration;
                this.points.splice(index, 1);
                for (var i = index; i < this.points.length; i++) {
                    var point = this.points[i];
                    point.index = i;
                    point.y = this.points[i].y;
                }
                var element = helper_2.getElement(this.accumulation.element.id + '_Series_0_Point_' + (this.points.length));
                Eif (element) {
                    element.parentNode.removeChild(element);
                }
                this.updateSeries(helper_2.getElement(this.accumulation.element.id + '_Series_' + this.index), undefined, 'removePoint', index);
                this.accumulation.redraw = false;
                this.accumulation.duration = chartDuration;
            }
        };
        AccumulationSeries.prototype.updateSeries = function (seriesGroup, maxLabelWidth, updatePoint, index) {
            var previousRadius = this.accumulation[(helper_2.firstToLowerCase(this.type) + 'SeriesModule')].radius;
            var previousCenter = this.accumulation[(helper_2.firstToLowerCase(this.type) + 'SeriesModule')].center;
            var previousLegendBounds;
            Eif (this.accumulation.legendSettings.visible) {
                if (updatePoint === 'addPoint') {
                    this.accumulation.accumulationLegendModule.
                        legendCollections.push(new legend_1.LegendOptions(this.points[this.points.length - 1].x.toString(), this.points[this.points.length - 1].color, this.legendShape, this.points[this.points.length - 1].visible, this.type, this.points[this.points.length - 1].legendImageUrl, null, null, this.points[this.points.length - 1].index, this.index));
                }
                else {
                    this.accumulation.accumulationLegendModule.legendCollections.splice(index, 1);
                    for (var i = index; i < this.accumulation.accumulationLegendModule.legendCollections.length; i++) {
                        this.accumulation.accumulationLegendModule.legendCollections[i].pointIndex = i;
                    }
                }
                Eif (this.accumulation.accumulationLegendModule.legendCollections.length >= 1) {
                    previousLegendBounds = this.accumulation.accumulationLegendModule.legendBounds;
                    this.accumulation.accumulationLegendModule.calculateLegendBounds(this.accumulation.initialClipRect, this.accumulation.availableSize, null, previousLegendBounds, true);
                    if (this.dataLabel && this.dataLabel.position === 'Outside' && (this.accumulation.legendSettings.position === 'Bottom' || (this.accumulation.legendSettings.position === 'Top')) ? (previousLegendBounds.height !== this.accumulation.accumulationLegendModule.legendBounds.height) : (previousLegendBounds.width !== this.accumulation.accumulationLegendModule.legendBounds.width)) {
                        var titleHeight = (this.accumulation.title ? ej2_svg_base_1.measureText(this.accumulation.title, this.accumulation.titleStyle, this.accumulation.themeStyle.chartTitleFont).height *
                            this.accumulation.titleCollection.length : 0);
                        var subTitleHeight = (this.accumulation.subTitle ?
                            (ej2_svg_base_1.measureText(this.accumulation.subTitle, this.accumulation.subTitleStyle, this.accumulation.themeStyle.chartSubTitleFont).height *
                                this.accumulation.subTitleCollection.length) : 0);
                        this.accumulation.initialClipRect = new ej2_svg_base_1.Rect(this.accumulation.margin.left, this.accumulation.margin.top, this.accumulation.availableSize.width, this.accumulation.availableSize.height);
                        helper_1.subtractRect(this.accumulation.initialClipRect, new ej2_svg_base_1.Rect(0, (subTitleHeight
                            + titleHeight), this.accumulation.margin.right +
                            this.accumulation.margin.left, this.accumulation.margin.bottom + this.accumulation.margin.top));
                        this.accumulation.accumulationLegendModule.calculateLegendBounds(this.accumulation.initialClipRect, this.accumulation.availableSize, null);
                    }
                }
            }
            this.accumulation[(helper_2.firstToLowerCase(this.type) + 'SeriesModule')].initProperties(this.accumulation, this);
            this.renderPoints(this.accumulation, seriesGroup, this.accumulation.redraw, previousRadius, previousCenter, true);
            if (previousLegendBounds && ((this.accumulation.legendSettings.position === 'Bottom' || (this.accumulation.legendSettings.position === 'Top')) ? (previousLegendBounds.height !== this.accumulation.accumulationLegendModule.legendBounds.height) : (previousLegendBounds.width !== this.accumulation.accumulationLegendModule.legendBounds.width)) && this.accumulation.centerLabel.text) {
                this.accumulation.renderCenterLabel(true, true);
            }
            if (this.accumulation.annotationModule) {
                this.accumulation.annotationModule.renderAnnotations(helper_2.getElement(this.accumulation.element.id + '_Secondary_Element'));
            }
            Eif (this.accumulation.accumulationDataLabelModule && this.dataLabel.visible) {
                var datalabelGroup = this.accumulation.renderer.createGroup({ id: this.accumulation.element.id + '_datalabel_Series_' + this.index });
                this.renderDataLabel(this.accumulation, datalabelGroup, this.accumulation.redraw);
            }
            Eif (this.accumulation.legendSettings.visible) {
                if (this.type === 'Pie') {
                    if (this.dataLabel.visible && this.points[this.points.length - 1] && this.points[this.points.length - 1].textSize.width > maxLabelWidth && this.accumulation.legendSettings.position !== 'Top' && this.accumulation.legendSettings.position !== 'Bottom') {
                        this.accumulation.visibleSeries[0].findMaxBounds(this.accumulation.visibleSeries[0].labelBound, this.points[this.points.length - 1].labelRegion);
                        this.findMaxBounds(this.labelBound, this.accumulationBound);
                        this.labelBound.x -= this.accumulation.explodeDistance;
                        this.labelBound.y -= this.accumulation.explodeDistance;
                        this.labelBound.height += (this.accumulation.explodeDistance - this.labelBound.y);
                        this.labelBound.width += (this.accumulation.explodeDistance - this.labelBound.x);
                    }
                    this.accumulation.accumulationLegendModule.getSmartLegendLocation(this.accumulation.visibleSeries[0].labelBound, this.accumulation.accumulationLegendModule.legendBounds, this.accumulation.margin);
                }
                this.accumulation.accumulationLegendModule.renderLegend(this.accumulation, this.accumulation.legendSettings, this.accumulation.accumulationLegendModule.legendBounds, this.accumulation.redraw, true);
            }
        };
        AccumulationSeries.prototype.isEmpty = function (point) {
            return point.color === this.emptyPointSettings.fill;
        };
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationSeries.prototype, "dataSource", void 0);
        __decorate([
            ej2_base_1.Property()
        ], AccumulationSeries.prototype, "query", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationSeries.prototype, "xName", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationSeries.prototype, "name", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationSeries.prototype, "tooltipMappingName", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationSeries.prototype, "yName", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], AccumulationSeries.prototype, "visible", void 0);
        __decorate([
            ej2_base_1.Complex({ color: null, width: 0 }, base_1.Border)
        ], AccumulationSeries.prototype, "border", void 0);
        __decorate([
            ej2_base_1.Complex(null, base_1.Animation)
        ], AccumulationSeries.prototype, "animation", void 0);
        __decorate([
            ej2_base_1.Property('SeriesType')
        ], AccumulationSeries.prototype, "legendShape", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationSeries.prototype, "legendImageUrl", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationSeries.prototype, "pointColorMapping", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], AccumulationSeries.prototype, "applyPattern", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationSeries.prototype, "selectionStyle", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationSeries.prototype, "groupTo", void 0);
        __decorate([
            ej2_base_1.Property('Value')
        ], AccumulationSeries.prototype, "groupMode", void 0);
        __decorate([
            ej2_base_1.Complex({}, AccumulationDataLabelSettings)
        ], AccumulationSeries.prototype, "dataLabel", void 0);
        __decorate([
            ej2_base_1.Property([])
        ], AccumulationSeries.prototype, "palettes", void 0);
        __decorate([
            ej2_base_1.Property(0)
        ], AccumulationSeries.prototype, "startAngle", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationSeries.prototype, "endAngle", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationSeries.prototype, "radius", void 0);
        __decorate([
            ej2_base_1.Property('0')
        ], AccumulationSeries.prototype, "innerRadius", void 0);
        __decorate([
            ej2_base_1.Property('Pie')
        ], AccumulationSeries.prototype, "type", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], AccumulationSeries.prototype, "enableTooltip", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], AccumulationSeries.prototype, "explode", void 0);
        __decorate([
            ej2_base_1.Property('30%')
        ], AccumulationSeries.prototype, "explodeOffset", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], AccumulationSeries.prototype, "explodeAll", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationSeries.prototype, "explodeIndex", void 0);
        __decorate([
            ej2_base_1.Complex({ mode: 'Drop' }, base_1.EmptyPointSettings)
        ], AccumulationSeries.prototype, "emptyPointSettings", void 0);
        __decorate([
            ej2_base_1.Property(0)
        ], AccumulationSeries.prototype, "gapRatio", void 0);
        __decorate([
            ej2_base_1.Property('80%')
        ], AccumulationSeries.prototype, "width", void 0);
        __decorate([
            ej2_base_1.Property('80%')
        ], AccumulationSeries.prototype, "height", void 0);
        __decorate([
            ej2_base_1.Property('20%')
        ], AccumulationSeries.prototype, "neckWidth", void 0);
        __decorate([
            ej2_base_1.Property('20%')
        ], AccumulationSeries.prototype, "neckHeight", void 0);
        __decorate([
            ej2_base_1.Property('Linear')
        ], AccumulationSeries.prototype, "pyramidMode", void 0);
        __decorate([
            ej2_base_1.Property(1)
        ], AccumulationSeries.prototype, "opacity", void 0);
        __decorate([
            ej2_base_1.Property('0')
        ], AccumulationSeries.prototype, "dashArray", void 0);
        __decorate([
            ej2_base_1.Property(0)
        ], AccumulationSeries.prototype, "borderRadius", void 0);
        return AccumulationSeries;
    }(ej2_base_1.ChildProperty));
    exports.AccumulationSeries = AccumulationSeries;
    function getSeriesFromIndex(index, visibleSeries) {
        for (var _i = 0, visibleSeries_1 = visibleSeries; _i < visibleSeries_1.length; _i++) {
            var series = visibleSeries_1[_i];
            Eif (index === series.index) {
                return series;
            }
        }
        return visibleSeries[0];
    }
    exports.getSeriesFromIndex = getSeriesFromIndex;
    function pointByIndex(index, points) {
        for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
            var point = points_1[_i];
            if (point.index === index) {
                return point;
            }
        }
        return null;
    }
    exports.pointByIndex = pointByIndex;
});