all files / accumulation-chart/ accumulation.js

99.08% Statements 429/433
90.87% Branches 209/230
100% Functions 59/59
99.06% Lines 422/426
16 statements, 6 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            12× 12× 12× 12×     7995× 7995×             226× 226× 226× 226×       226× 226×   226×   226× 226× 226× 226× 226× 226×   452× 452× 452× 452× 452× 452× 452× 452× 452× 452× 452× 452×   226× 226× 226× 226× 226× 226× 226× 226× 226× 226× 226× 226× 226× 226×   110× 110× 110× 110× 110×     108× 108× 108×   110× 110×             256× 256× 256×           256× 245×   256× 14× 13× 13×     256×       226× 226× 226× 226× 226× 226×             21× 21× 21×   21× 15×   21×   21× 21×   21× 21×   23× 23×     22×     82× 82× 77×   82× 69×   82× 24×   82× 82×   82×                   226×   250× 250×   259× 259× 247× 898×   247× 247×     259× 259×   259×         226× 226× 226× 226× 226× 226×       229× 229× 229× 229× 229× 229×     228× 228× 228× 228× 228× 220×     228× 228×       243× 243× 243× 243× 243×   243× 68×   175× 175×   259× 259× 259× 259× 259× 259× 259× 259× 259× 259× 259× 259×   259× 259×   258× 258× 258× 258×   259× 41×     259× 211×   48×   259× 259× 259× 259× 259× 259×       259× 259×   259× 71×   188× 173× 100×   173×     259× 213×   46× 46× 46×     259× 183×   76× 76×   76×   413×   16× 16× 16×     25× 213× 213× 213× 213×     722×   226× 226× 226×   443× 443× 443×       443× 309×         443× 237×         443× 24×         443× 71×         443× 432×   443× 73×         443×   443× 443× 443× 237×     206×     30×     30× 44× 44×           15× 15×                                                     30×   23× 15× 15× 15× 15×                                                                                                                                                              
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var 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 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-base", "../common/model/base", "./model/acc-base", "../common/model/theme", "../common/model/constants", "../common/model/constants", "../common/model/constants", "../common/legend/legend", "../common/utils/helper", "../common/utils/helper", "../common/utils/helper", "../common/utils/helper", "../common/model/data", "./renderer/accumulation-base", "./renderer/pie-series", "./model/acc-base", "../common/utils/export", "../common/utils/helper"], function (require, exports, ej2_base_1, ej2_base_2, ej2_base_3, base_1, acc_base_1, theme_1, constants_1, constants_2, constants_3, legend_1, helper_1, helper_2, helper_3, helper_4, data_1, accumulation_base_1, pie_series_1, acc_base_2, export_1, helper_5) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AccumulationChart = (function (_super) {
        __extends(AccumulationChart, _super);
        function AccumulationChart(options, element) {
            var _this = _super.call(this, options, element) || this;
            _this.explodeDistance = 0;
            _this.chartid = 57724;
            return _this;
        }
        Object.defineProperty(AccumulationChart.prototype, "type", {
            get: function () {
                Eif (this.series && this.series.length) {
                    return this.series[0].type;
                }
                return 'Pie';
            },
            enumerable: true,
            configurable: true
        });
        AccumulationChart.prototype.preRender = function () {
            this.unWireEvents();
            this.setCulture();
            this.animateSeries = true;
            Iif (this.element.id === '') {
                var collection = document.getElementsByClassName('e-accumulationchart').length;
                this.element.id = 'acc_chart_' + this.chartid + '_' + collection;
            }
            helper_3.calculateSize(this);
            this.wireEvents();
        };
        AccumulationChart.prototype.setTheme = function () {
            this.themeStyle = theme_1.getThemeColor(this.theme);
        };
        AccumulationChart.prototype.render = function () {
            this.trigger(constants_1.load, { accumulation: this });
            this.setTheme();
            this.accBaseModule = new accumulation_base_1.AccumulationBase(this);
            this.pieSeriesModule = new pie_series_1.PieSeries(this);
            this.calculateVisibleSeries();
            this.processData();
        };
        AccumulationChart.prototype.unWireEvents = function () {
            var isIE11Pointer = ej2_base_2.Browser.isPointer;
            var start = ej2_base_2.Browser.touchStartEvent;
            var move = ej2_base_2.Browser.touchMoveEvent;
            var stop = ej2_base_2.Browser.touchEndEvent;
            var cancel = isIE11Pointer ? 'pointerleave' : 'mouseleave';
            ej2_base_2.EventHandler.remove(this.element, move, this.accumulationMouseMove);
            ej2_base_2.EventHandler.remove(this.element, stop, this.accumulationMouseEnd);
            ej2_base_2.EventHandler.remove(this.element, start, this.accumulationMouseStart);
            ej2_base_2.EventHandler.remove(this.element, 'click', this.accumulationOnMouseClick);
            ej2_base_2.EventHandler.remove(this.element, 'contextmenu', this.accumulationRightClick);
            ej2_base_2.EventHandler.remove(this.element, cancel, this.accumulationMouseLeave);
            window.removeEventListener((ej2_base_2.Browser.isTouch && ('orientation' in window && 'onorientationchange' in window)) ? 'orientationchange' : 'resize', this.accumulationResize);
        };
        AccumulationChart.prototype.wireEvents = function () {
            var isIE11Pointer = ej2_base_2.Browser.isPointer;
            var start = ej2_base_2.Browser.touchStartEvent;
            var stop = ej2_base_2.Browser.touchEndEvent;
            var move = ej2_base_2.Browser.touchMoveEvent;
            var cancel = isIE11Pointer ? 'pointerleave' : 'mouseleave';
            ej2_base_2.EventHandler.add(this.element, move, this.accumulationMouseMove, this);
            ej2_base_2.EventHandler.add(this.element, stop, this.accumulationMouseEnd, this);
            ej2_base_2.EventHandler.add(this.element, start, this.accumulationMouseStart, this);
            ej2_base_2.EventHandler.add(this.element, 'click', this.accumulationOnMouseClick, this);
            ej2_base_2.EventHandler.add(this.element, 'contextmenu', this.accumulationRightClick, this);
            ej2_base_2.EventHandler.add(this.element, cancel, this.accumulationMouseLeave, this);
            window.addEventListener((ej2_base_2.Browser.isTouch && ('orientation' in window && 'onorientationchange' in window)) ? 'orientationchange' : 'resize', this.accumulationResize.bind(this));
            new ej2_base_2.Touch(this.element);
            this.setStyle(this.element);
        };
        AccumulationChart.prototype.setMouseXY = function (e) {
            var pageX;
            var pageY;
            var svgRect = helper_4.getElement(this.element.id + '_svg').getBoundingClientRect();
            var rect = this.element.getBoundingClientRect();
            if (e.type.indexOf('touch') > -1) {
                this.isTouch = true;
                var touchArg = e;
                pageY = touchArg.changedTouches[0].clientY;
                pageX = touchArg.changedTouches[0].clientX;
            }
            else {
                this.isTouch = e.pointerType === 'touch' || e.pointerType === '2';
                pageX = e.clientX;
                pageY = e.clientY;
            }
            this.mouseY = (pageY - rect.top) - Math.max(svgRect.top - rect.top, 0);
            this.mouseX = (pageX - rect.left) - Math.max(svgRect.left - rect.left, 0);
        };
        AccumulationChart.prototype.accumulationMouseEnd = function (e) {
            this.setMouseXY(e);
            this.trigger(constants_3.chartMouseUp, { target: e.target.id, x: this.mouseX, y: this.mouseY });
            if (this.isTouch) {
                this.titleTooltip(e, this.mouseX, this.mouseY, this.isTouch);
                if (this.accumulationDataLabelModule && this.visibleSeries[0].dataLabel.visible) {
                    this.accumulationDataLabelModule.move(e, this.mouseX, this.mouseY, this.isTouch);
                }
                Eif (this.accumulationLegendModule && this.legendSettings.visible) {
                    this.accumulationLegendModule.move(e);
                }
            }
            this.notify(ej2_base_2.Browser.touchEndEvent, e);
            return false;
        };
        AccumulationChart.prototype.accumulationMouseStart = function (e) {
            this.setMouseXY(e);
            this.trigger(constants_2.chartMouseDown, { target: e.target.id, x: this.mouseX, y: this.mouseY });
            return false;
        };
        AccumulationChart.prototype.accumulationResize = function (e) {
            var _this = this;
            this.animateSeries = false;
            var args = {
                accumulation: this,
                previousSize: new helper_1.Size(this.availableSize.width, this.availableSize.height),
                name: constants_3.resized,
                currentSize: new helper_1.Size(0, 0)
            };
            if (this.resizeTo) {
                clearTimeout(this.resizeTo);
            }
            this.resizeTo = setTimeout(function () {
                if (_this.isDestroyed) {
                    clearTimeout(_this.resizeTo);
                    return;
                }
                helper_3.calculateSize(_this);
                args.currentSize = _this.availableSize;
                _this.trigger(constants_3.resized, args);
                _this.refreshSeries();
                _this.refreshChart();
            }, 500);
            return false;
        };
        AccumulationChart.prototype.export = function (type, fileName, orientation, controls, width, height) {
            var exportChart = new export_1.ExportUtils(this);
            exportChart.export(type, fileName, orientation, (controls ? controls : [this]), width, height);
        };
        AccumulationChart.prototype.print = function (id) {
            var exportChart = new export_1.ExportUtils(this);
            exportChart.print(id);
        };
        AccumulationChart.prototype.setStyle = function (element) {
            element.style.touchAction = 'element';
            element.style.msTouchAction = 'element';
            element.style.msContentZooming = 'none';
            element.style.msUserSelect = 'none';
            element.style.webkitUserSelect = 'none';
            element.style.position = 'relative';
        };
        AccumulationChart.prototype.setAnnotationValue = function (annotationIndex, content) {
            var annotation = this.annotations[annotationIndex];
            var element;
            var parentNode = helper_4.getElement(this.element.id + '_Annotation_Collections');
            Eif (content) {
                annotation.content = content;
                if (parentNode) {
                    element = ej2_base_3.createElement('div');
                    helper_3.removeElement(this.element.id + '_Annotation_' + annotationIndex);
                    this.annotationModule.processAnnotation(annotation, annotationIndex, element);
                    parentNode.appendChild(element.children[0]);
                }
                else {
                    this.annotationModule.renderAnnotations(helper_4.getElement(this.element.id + '_Secondary_Element'));
                }
            }
        };
        AccumulationChart.prototype.accumulationMouseMove = function (e) {
            this.setMouseXY(e);
            this.trigger(constants_3.chartMouseMove, { target: e.target.id, x: this.mouseX, y: this.mouseY });
            if (this.pointMove) {
                this.triggerPointEvent(constants_2.pointMove, e.target);
            }
            if (this.accumulationLegendModule && this.legendSettings.visible) {
                this.accumulationLegendModule.move(e);
            }
            if (this.accumulationDataLabelModule && this.visibleSeries[0] && this.visibleSeries[0].dataLabel.visible) {
                this.accumulationDataLabelModule.move(e, this.mouseX, this.mouseY);
            }
            Eif (!this.isTouch) {
                this.titleTooltip(e, this.mouseX, this.mouseY);
            }
            this.notify(ej2_base_2.Browser.touchMoveEvent, e);
            return false;
        };
        AccumulationChart.prototype.titleTooltip = function (event, x, y, isTouch) {
            var targetId = event.target.id;
            if ((event.target.textContent.indexOf('...') > -1) && (targetId === (this.element.id + '_title'))) {
                helper_2.showTooltip(this.title, x, y, this.element.offsetWidth, this.element.id + '_EJ2_Title_Tooltip', helper_4.getElement(this.element.id + '_Secondary_Element'), isTouch);
            }
            else {
                helper_3.removeElement(this.element.id + '_EJ2_Title_Tooltip');
            }
        };
        AccumulationChart.prototype.accumulationOnMouseClick = function (e) {
            this.setMouseXY(e);
            if (this.accumulationLegendModule && this.legendSettings.visible) {
                this.accumulationLegendModule.click(e);
            }
            if (this.selectionMode !== 'None' && this.accumulationSelectionModule) {
                this.accumulationSelectionModule.calculateSelectedElements(this, e);
            }
            if (this.visibleSeries[0].explode) {
                this.accBaseModule.processExplode(e);
            }
            this.trigger(constants_2.chartMouseClick, { target: e.target.id, x: this.mouseX, y: this.mouseY });
            if (this.pointClick) {
                this.triggerPointEvent(constants_1.pointClick, e.target);
            }
            return false;
        };
        AccumulationChart.prototype.triggerPointEvent = function (event, element) {
            var indexes = helper_1.indexFinder(element.id, true);
            Eif (indexes.series >= 0 && indexes.point >= 0) {
                this.trigger(event, { series: this.series[indexes.series],
                    point: this.series[indexes.series].points[indexes.point],
                    seriesIndex: indexes.series, pointIndex: indexes.point,
                    x: this.mouseX, y: this.mouseY });
            }
        };
        AccumulationChart.prototype.accumulationRightClick = function (event) {
            if (event.buttons === 2 || event.pointerType === 'touch') {
                event.preventDefault();
                event.stopPropagation();
                return false;
            }
            return true;
        };
        AccumulationChart.prototype.accumulationMouseLeave = function (e) {
            this.setMouseXY(e);
            this.trigger(constants_3.chartMouseLeave, { target: e.target.id, x: this.mouseX, y: this.mouseY });
            this.notify(ej2_base_2.Browser.isPointer ? 'pointerleave' : 'mouseleave', e);
            return false;
        };
        AccumulationChart.prototype.setCulture = function () {
            this.intl = new ej2_base_2.Internationalization();
        };
        AccumulationChart.prototype.createPieSvg = function () {
            this.removeSvg();
            helper_3.createSvg(this);
        };
        AccumulationChart.prototype.removeSvg = function () {
            helper_3.removeElement(this.element.id + '_Secondary_Element');
            if (this.svgObject) {
                while (this.svgObject.childNodes.length > 0) {
                    this.svgObject.removeChild(this.svgObject.firstChild);
                }
                Eif (!this.svgObject.hasChildNodes() && this.svgObject.parentNode) {
                    ej2_base_3.remove(this.svgObject);
                }
            }
            helper_3.removeElement('EJ2_legend_tooltip');
            helper_3.removeElement('EJ2_datalabel_tooltip');
        };
        AccumulationChart.prototype.createSecondaryElement = function () {
            this.element.appendChild(ej2_base_3.createElement('div', {
                id: this.element.id + '_Secondary_Element',
                styles: 'position: relative'
            }));
        };
        AccumulationChart.prototype.calculateVisibleSeries = function () {
            this.visibleSeries = [];
            for (var i = 0, length_1 = this.series.length; i < length_1; i++) {
                this.series[i].index = i;
                Eif (this.series[i].type === this.type && this.visibleSeries.length === 0) {
                    this.visibleSeries.push(this.series[i]);
                    break;
                }
            }
        };
        AccumulationChart.prototype.processData = function (render) {
            if (render === void 0) { render = true; }
            this.seriesCounts = 0;
            for (var _i = 0, _a = this.visibleSeries; _i < _a.length; _i++) {
                var series = _a[_i];
                series.dataModule = new data_1.Data(series.dataSource || this.dataSource, series.query);
                series.refreshDataManager(this, render);
            }
        };
        AccumulationChart.prototype.refreshChart = function () {
            this.doGrouppingProcess();
            this.createPieSvg();
            this.calculateBounds();
            this.renderElements();
            if (document.getElementById('chartmeasuretext')) {
                document.getElementById('chartmeasuretext').remove();
            }
        };
        AccumulationChart.prototype.doGrouppingProcess = function () {
            var series = this.visibleSeries[0];
            if (!ej2_base_3.isNullOrUndefined(series.resultData) && ((!ej2_base_3.isNullOrUndefined(series.lastGroupTo) &&
                series.lastGroupTo !== series.groupTo))) {
                series.getPoints(series.resultData, this);
            }
        };
        AccumulationChart.prototype.calculateBounds = function () {
            this.initialClipRect = new helper_1.Rect(this.margin.left, this.margin.top, this.availableSize.width, this.availableSize.height);
            this.titleCollection = [];
            this.titleCollection = helper_5.getTitle(this.title, this.titleStyle, this.initialClipRect.width);
            helper_1.subtractRect(this.initialClipRect, new helper_1.Rect(0, (helper_2.measureText(this.title, this.titleStyle).height * this.titleCollection.length), this.margin.right + this.margin.left, this.margin.bottom + this.margin.top));
            this.calculateLegendBounds();
        };
        AccumulationChart.prototype.calculateLegendBounds = function () {
            if (!this.accumulationLegendModule || !this.legendSettings.visible) {
                return null;
            }
            this.accumulationLegendModule.getLegendOptions(this, this.visibleSeries);
            this.accumulationLegendModule.calculateLegendBounds(this.initialClipRect, this.availableSize);
        };
        AccumulationChart.prototype.renderElements = function () {
            this.renderBorder();
            this.renderTitle();
            this.createSecondaryElement();
            this.renderSeries();
            this.renderLegend();
            this.element.appendChild(this.svgObject);
            this.processSelection();
            this.processExplode();
            this.renderAnnotation();
            this.setSecondaryElementPosition();
            this.trigger('loaded', { accumulation: this });
            this.animateSeries = false;
        };
        AccumulationChart.prototype.setSecondaryElementPosition = function () {
            var tooltipParent = helper_4.getElement(this.element.id + '_Secondary_Element');
            if (!tooltipParent) {
                return;
            }
            var rect = this.element.getBoundingClientRect();
            var svgRect = helper_4.getElement(this.element.id + '_svg').getBoundingClientRect();
            tooltipParent.style.left = Math.max(svgRect.left - rect.left, 0) + 'px';
            tooltipParent.style.top = Math.max(svgRect.top - rect.top, 0) + 'px';
        };
        AccumulationChart.prototype.renderAnnotation = function () {
            if (this.annotationModule) {
                this.annotationModule.renderAnnotations(helper_4.getElement(this.element.id + '_Secondary_Element'));
            }
        };
        AccumulationChart.prototype.processExplode = function () {
            if (!this.visibleSeries[0].explode) {
                return null;
            }
            this.accBaseModule.invokeExplode();
        };
        AccumulationChart.prototype.renderSeries = function () {
            this.svgObject.appendChild(this.renderer.createGroup({ id: this.element.id + '_SeriesCollection' }));
            for (var _i = 0, _a = this.visibleSeries; _i < _a.length; _i++) {
                var series = _a[_i];
                Eif (series.visible && this[(helper_3.firstToLowerCase(series.type) + 'SeriesModule')]) {
                    this[(helper_3.firstToLowerCase(series.type) + 'SeriesModule')].initProperties(this, series);
                    series.renderSeries(this);
                }
            }
        };
        AccumulationChart.prototype.renderBorder = function () {
            var padding = this.border.width;
            this.svgObject.appendChild(this.renderer.drawRectangle(new helper_2.RectOption(this.element.id + '_border', this.background || this.themeStyle.background, this.border, 1, new helper_1.Rect(padding / 2, padding / 2, this.availableSize.width - padding, this.availableSize.height - padding))));
        };
        AccumulationChart.prototype.renderLegend = function () {
            if (!this.accumulationLegendModule || !this.legendSettings.visible) {
                return null;
            }
            if (this.accumulationLegendModule.legendCollections.length) {
                if (this.visibleSeries[0].type === 'Pie') {
                    this.accumulationLegendModule.getSmartLegendLocation(this.visibleSeries[0].labelBound, this.accumulationLegendModule.legendBounds, this.margin);
                }
                this.accumulationLegendModule.renderLegend(this, this.legendSettings, this.accumulationLegendModule.legendBounds);
            }
        };
        AccumulationChart.prototype.processSelection = function () {
            if (!this.accumulationSelectionModule || this.selectionMode === 'None') {
                return null;
            }
            var selectedDataIndexes = ej2_base_3.extend([], this.accumulationSelectionModule.selectedDataIndexes, null, true);
            this.accumulationSelectionModule.invokeSelection(this);
            if (selectedDataIndexes.length > 0) {
                this.accumulationSelectionModule.selectedDataIndexes = selectedDataIndexes;
                this.accumulationSelectionModule.redrawSelection(this, this.selectionMode);
            }
        };
        AccumulationChart.prototype.renderTitle = function () {
            if (!this.title) {
                return null;
            }
            var titleSize = helper_2.measureText(this.title, this.titleStyle);
            var anchor = this.titleStyle.textAlignment === 'Near' ? 'start' :
                this.titleStyle.textAlignment === 'Far' ? 'end' : 'middle';
            helper_3.textElement(new helper_3.TextOption(this.element.id + '_title', helper_4.titlePositionX(this.availableSize, this.margin.left, this.margin.left, this.titleStyle), this.margin.top + (titleSize.height * 3 / 4), anchor, this.titleCollection, '', 'auto'), this.titleStyle, this.titleStyle.color || this.themeStyle.chartTitle, this.svgObject);
        };
        AccumulationChart.prototype.getSeriesElement = function () {
            return this.svgObject.getElementsByTagName('g')[0];
        };
        AccumulationChart.prototype.refreshSeries = function () {
            for (var _i = 0, _a = this.visibleSeries; _i < _a.length; _i++) {
                var series = _a[_i];
                this.refreshPoints(series.points);
            }
        };
        AccumulationChart.prototype.refreshPoints = function (points) {
            for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
                var point = points_1[_i];
                point.labelPosition = null;
                point.labelRegion = null;
                point.labelVisible = true;
            }
        };
        AccumulationChart.prototype.getModuleName = function () {
            return 'accumulationchart';
        };
        AccumulationChart.prototype.destroy = function () {
            this.unWireEvents();
            _super.prototype.destroy.call(this);
            this.element.classList.remove('e-accumulationchart');
        };
        AccumulationChart.prototype.requiredModules = function () {
            var modules = [];
            var enableAnnotation = false;
            modules.push({
                member: this.type + 'Series',
                args: [this]
            });
            if (this.legendSettings.visible) {
                modules.push({
                    member: 'AccumulationLegend',
                    args: [this]
                });
            }
            if (this.findDatalabelVisibility()) {
                modules.push({
                    member: 'AccumulationDataLabel',
                    args: [this]
                });
            }
            if (this.tooltip.enable) {
                modules.push({
                    member: 'AccumulationTooltip',
                    args: [this]
                });
            }
            if (this.selectionMode !== 'None') {
                modules.push({
                    member: 'AccumulationSelection',
                    args: [this]
                });
            }
            enableAnnotation = this.annotations.some(function (value) {
                return (value.content !== null);
            });
            if (enableAnnotation) {
                modules.push({
                    member: 'Annotation',
                    args: [this]
                });
            }
            return modules;
        };
        AccumulationChart.prototype.findDatalabelVisibility = function () {
            for (var _i = 0, _a = this.series; _i < _a.length; _i++) {
                var series = _a[_i];
                if (series.dataLabel.visible) {
                    return true;
                }
            }
            return false;
        };
        AccumulationChart.prototype.getPersistData = function () {
            return '';
        };
        AccumulationChart.prototype.onPropertyChanged = function (newProp, oldProp) {
            var update = {
                refreshElements: false, refreshBounds: false
            };
            for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
                var prop = _a[_i];
                switch (prop) {
                    case 'theme':
                        this.animateSeries = true;
                        break;
                    case 'title':
                    case 'height':
                    case 'width':
                    case 'margin':
                        update.refreshBounds = true;
                        break;
                    case 'titleStyle':
                        Eif (newProp.titleStyle && (newProp.titleStyle.size || newProp.titleStyle.textOverflow)) {
                            update.refreshBounds = true;
                        }
                        else {
                            update.refreshElements = true;
                        }
                        break;
                    case 'legendSettings':
                        update.refreshBounds = true;
                        update.refreshElements = true;
                        break;
                    case 'dataSource':
                        this.processData(false);
                        update.refreshBounds = true;
                        break;
                    case 'series':
                        var len = this.series.length;
                        var seriesRefresh = false;
                        for (var i = 0; i < len; i++) {
                            if (newProp.series[i] && (newProp.series[i].dataSource || newProp.series[i].yName || newProp.series[i].xName)) {
                                seriesRefresh = true;
                            }
                        }
                        if (seriesRefresh) {
                            this.processData(false);
                            update.refreshBounds = true;
                        }
                        break;
                    case 'locale':
                    case 'currencyCode':
                        _super.prototype.refresh.call(this);
                        break;
                    case 'background':
                    case 'border':
                    case 'annotations':
                    case 'enableSmartLabels':
                        update.refreshElements = true;
                        break;
                    case 'isMultiSelect':
                    case 'selectedDataIndexes':
                    case 'selectionMode':
                        Eif (this.accumulationSelectionModule) {
                            if (ej2_base_3.isNullOrUndefined(this.accumulationSelectionModule.selectedDataIndexes)) {
                                this.accumulationSelectionModule.invokeSelection(this);
                            }
                            else {
                                this.accumulationSelectionModule.redrawSelection(this, oldProp.selectionMode);
                            }
                        }
                        break;
                }
            }
            if (!update.refreshBounds && update.refreshElements) {
                this.createPieSvg();
                this.renderElements();
            }
            else if (update.refreshBounds) {
                this.refreshSeries();
                this.createPieSvg();
                this.calculateBounds();
                this.renderElements();
            }
        };
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationChart.prototype, "width", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationChart.prototype, "height", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationChart.prototype, "title", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], AccumulationChart.prototype, "dataSource", void 0);
        __decorate([
            ej2_base_1.Complex(theme_1.Theme.chartTitleFont, base_1.Font)
        ], AccumulationChart.prototype, "titleStyle", void 0);
        __decorate([
            ej2_base_1.Complex({}, legend_1.LegendSettings)
        ], AccumulationChart.prototype, "legendSettings", void 0);
        __decorate([
            ej2_base_1.Complex({}, base_1.TooltipSettings)
        ], AccumulationChart.prototype, "tooltip", void 0);
        __decorate([
            ej2_base_1.Property('None')
        ], AccumulationChart.prototype, "selectionMode", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], AccumulationChart.prototype, "isMultiSelect", void 0);
        __decorate([
            ej2_base_1.Collection([], base_1.Indexes)
        ], AccumulationChart.prototype, "selectedDataIndexes", void 0);
        __decorate([
            ej2_base_1.Complex({}, base_1.Margin)
        ], AccumulationChart.prototype, "margin", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], AccumulationChart.prototype, "enableSmartLabels", void 0);
        __decorate([
            ej2_base_1.Complex({ color: '#DDDDDD', width: 0 }, base_1.Border)
        ], AccumulationChart.prototype, "border", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], AccumulationChart.prototype, "background", void 0);
        __decorate([
            ej2_base_1.Collection([{}], acc_base_1.AccumulationSeries)
        ], AccumulationChart.prototype, "series", void 0);
        __decorate([
            ej2_base_1.Collection([{}], acc_base_2.AccumulationAnnotationSettings)
        ], AccumulationChart.prototype, "annotations", void 0);
        __decorate([
            ej2_base_1.Property('Material')
        ], AccumulationChart.prototype, "theme", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "loaded", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "load", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "seriesRender", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "legendRender", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "textRender", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "tooltipRender", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "pointRender", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "annotationRender", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "beforePrint", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "chartMouseMove", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "chartMouseClick", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "pointClick", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "pointMove", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "animationComplete", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "chartMouseDown", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "chartMouseLeave", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "chartMouseUp", void 0);
        __decorate([
            ej2_base_2.Event()
        ], AccumulationChart.prototype, "resized", void 0);
        __decorate([
            ej2_base_1.Property('USD')
        ], AccumulationChart.prototype, "currencyCode", void 0);
        AccumulationChart = __decorate([
            ej2_base_1.NotifyPropertyChanges
        ], AccumulationChart);
        return AccumulationChart;
    }(ej2_base_1.Component));
    exports.AccumulationChart = AccumulationChart;
});