all files / heatmap/series/ series.js

97.52% Statements 354/363
92.41% Branches 292/316
100% Functions 30/30
97.48% Lines 348/357
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              33×                                             267× 267× 267×   336× 336× 336× 336× 336× 336× 336× 336× 336× 336× 336×   336×   336× 336× 336× 336× 336× 336× 336× 336× 336× 336× 63×   336× 10×     10×       336× 336× 22330× 50× 50×   22280× 25× 25×   22330× 22330× 22330× 22330× 606×     21724×   22330× 22300× 21554×     746× 746× 710×         30×   22330× 22330× 296×   22330×   54×   22330× 21534× 21534×     796× 24× 24×   772×   625× 25×   25×     625× 625× 625×   147× 24× 24× 24×     22330× 22330× 330× 330×   22330× 8762× 8762× 8762× 8762× 300×   8762×     8762×   22330× 3643× 3643× 3643× 3643× 732×     2911×   3643× 3643× 3643×     18687× 18687× 18687×     336× 10×   336× 285× 285× 283×       330× 330× 573× 573×     573× 150×       423×       573× 573×   573×   573× 150×   423× 180× 39× 39×     141× 141×     243×           330×   296× 296× 296× 296× 296× 296×                       296× 296× 296×   22330× 22330× 22330× 22330× 606×   606×       606× 606× 606×                 21724× 21724×     336× 285×     285×   283×       22330× 22330× 22330× 22330× 22330× 22330× 22330× 22330×   21534× 21534×   336× 336× 303×   336×   24× 24× 24× 24× 24× 24× 24× 24× 24× 24× 24× 24× 24× 24× 24× 42× 42× 24× 24× 24×     18×   24× 24× 24× 24× 24×       18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18×     42× 42× 42× 42× 42×       42× 42×     18×     12× 12×           18× 18×   24×     24× 24×     649× 649×   22183× 21407× 21407×       649× 649× 649×     649×     649×   649× 649×   595×     595×   649× 649×   8762× 8762× 8762× 8762× 8762×   74× 74× 42×   42× 42× 33× 32× 32×   32×   32× 23×     33×       32× 31× 31×   31×               21610× 21610× 21610×     21610× 21610× 21191×   21610×   361× 361× 361× 361×       361×       361× 361× 361× 361× 361× 361× 361×   263× 263×   263× 263× 263× 263× 263× 263× 263× 263× 263× 263×        
/* 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", "../utils/helper", "../utils/helper", "../utils/colorMapping", "../model/base", "../model/theme"], function (require, exports, ej2_base_1, helper_1, helper_2, colorMapping_1, base_1, theme_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var CellSettings = (function (_super) {
        __extends(CellSettings, _super);
        function CellSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property('')
        ], CellSettings.prototype, "labelTemplate", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], CellSettings.prototype, "showLabel", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], CellSettings.prototype, "format", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], CellSettings.prototype, "enableCellHighlighting", void 0);
        __decorate([
            ej2_base_1.Complex({}, base_1.BubbleSize)
        ], CellSettings.prototype, "bubbleSize", void 0);
        __decorate([
            ej2_base_1.Complex({}, base_1.Border)
        ], CellSettings.prototype, "border", void 0);
        __decorate([
            ej2_base_1.Complex(theme_1.Theme.rectLabelFont, base_1.Font)
        ], CellSettings.prototype, "textStyle", void 0);
        __decorate([
            ej2_base_1.Property('Rect')
        ], CellSettings.prototype, "tileType", void 0);
        __decorate([
            ej2_base_1.Property('Color')
        ], CellSettings.prototype, "bubbleType", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], CellSettings.prototype, "isInversedBubbleSize", void 0);
        return CellSettings;
    }(ej2_base_1.ChildProperty));
    exports.CellSettings = CellSettings;
    var Series = (function () {
        function Series(heatMap) {
            this.heatMap = heatMap;
            this.drawSvgCanvas = new helper_1.DrawSvgCanvas(this.heatMap);
            this.cellColor = new colorMapping_1.CellColor(this.heatMap);
        }
        Series.prototype.renderRectSeries = function () {
            this.createSeriesGroup();
            var heatMap = this.heatMap;
            var isValueInRange = false;
            heatMap.xLength = heatMap.axisCollections[0].axisLabelSize;
            heatMap.yLength = heatMap.axisCollections[1].axisLabelSize;
            var tempX = Math.round(heatMap.initialClipRect.x * 100) / 100;
            var tempY = Math.round(heatMap.initialClipRect.y * 100) / 100;
            var dataXIndex = 0;
            var dataYIndex = 0;
            var cellSetting = heatMap.cellSettings;
            var tempWidth = Math.round(((heatMap.initialClipRect.width -
                (cellSetting.border.width / 2)) / heatMap.xLength) * 100) / 100;
            var tempHeight = Math.round(((heatMap.initialClipRect.height -
                (cellSetting.border.width / 2)) / heatMap.yLength) * 100) / 100;
            var tempVal = 0;
            var tempRectPosition = [];
            var tempBorder = cellSetting.border;
            var borderColor;
            var templateElement = null;
            var displayText;
            this.rectPositionCollection = [];
            this.color = '';
            this.bubbleColorValue = [];
            if (heatMap.yAxis.opposedPosition) {
                tempX = Math.round((heatMap.initialClipRect.x + (parseFloat(tempBorder.width.toString()) / 2)) * 100) / 100;
            }
            if (!ej2_base_1.isNullOrUndefined(this.heatMap.cellSettings.labelTemplate) && this.heatMap.cellSettings.labelTemplate !== '') {
                Iif (document.getElementById(this.heatMap.element.id + '_LabelTemplate_Group')) {
                    helper_2.removeElement(this.heatMap.element.id + '_LabelTemplate_Group');
                }
                templateElement = ej2_base_1.createElement('div', {
                    id: heatMap.element.id + '_LabelTemplate_Group'
                });
            }
            var circleRadius = this.getBubbleRadius(tempWidth, tempHeight);
            for (var x = 0; x < (heatMap.xLength * heatMap.yLength); x++) {
                if (heatMap.paletteSettings.colorGradientMode === 'Column' && this.heatMap.paletteSettings.type === 'Gradient') {
                    this.heatMap.dataSourceMinValue = this.heatMap.dataMin[dataYIndex];
                    this.heatMap.dataSourceMaxValue = this.heatMap.dataMax[dataYIndex];
                }
                else if (heatMap.paletteSettings.colorGradientMode === 'Row' && this.heatMap.paletteSettings.type === 'Gradient') {
                    this.heatMap.dataSourceMinValue = this.heatMap.dataMin[dataXIndex];
                    this.heatMap.dataSourceMaxValue = this.heatMap.dataMax[dataXIndex];
                }
                this.setTextAndColor(dataXIndex, dataYIndex);
                var rectPosition = new helper_1.CurrentRect(0, 0, 0, 0, 0, '', 0, 0, 0, 0, true, '', '', true);
                borderColor = tempBorder.color;
                if (this.heatMap.bubbleSizeWithColor) {
                    this.updateRectDetails(rectPosition, tempX, tempY, tempWidth, tempHeight, ej2_base_1.extend('', this.bubbleColorValue, null, true), x, dataYIndex, dataXIndex);
                }
                else {
                    this.updateRectDetails(rectPosition, tempX, tempY, tempWidth, tempHeight, this.text, x, dataYIndex, dataXIndex);
                }
                if (cellSetting.showLabel) {
                    if (ej2_base_1.isNullOrUndefined(this.heatMap.cellSettings.labelTemplate) || this.heatMap.cellSettings.labelTemplate === '') {
                        displayText = this.getFormatedText(this.text, cellSetting.format);
                    }
                    else {
                        var rectValue = heatMap.dataSourceSettings.bubbleDataMapping && heatMap.dataSourceSettings.isJsonData && heatMap.dataSourceSettings.adaptorType === 'Cell' && !ej2_base_1.isNullOrUndefined(rectPosition.value[0]) ? rectPosition.value[0].bubbleData : rectPosition.value;
                        if (typeof rectValue == 'number' && this.cellColor.getColorByValue(rectValue) !== '#ffffff') {
                            helper_1.createLabelTemplate(this.heatMap.cellSettings.labelTemplate, heatMap, templateElement, rectPosition, heatMap.axisCollections[0].axisLabels, heatMap.axisCollections[1].axisLabels.slice().reverse(), x);
                        }
                    }
                }
                else {
                    displayText = '';
                }
                rectPosition.displayText = displayText;
                if (!ej2_base_1.isNullOrUndefined(this.heatMap.cellRender)) {
                    displayText = this.cellRendering(rectPosition, displayText);
                }
                if ((heatMap.renderingMode === 'Canvas' && parseFloat(tempBorder.width.toString()) === 0) || (!borderColor &&
                    cellSetting.tileType === 'Bubble' && cellSetting.bubbleType === 'Sector')) {
                    borderColor = this.color;
                }
                if (cellSetting.tileType === 'Rect') {
                    this.renderTileCell(rectPosition, tempBorder, x, this.color, borderColor);
                    this.updateLabelVisibleStatus(tempWidth, tempHeight, displayText);
                }
                else {
                    if (cellSetting.bubbleType === 'Color') {
                        this.renderBubbleCell(rectPosition, tempBorder, x, this.color, borderColor, circleRadius);
                        this.updateLabelVisibleStatus((circleRadius * 2) - 12, (circleRadius * 2) - 6, displayText);
                    }
                    else if (!ej2_base_1.isNullOrUndefined(this.text) && (cellSetting.bubbleType === 'Size' || cellSetting.bubbleType === 'SizeAndColor')
                        && this.text.toString() !== '') {
                        if (this.heatMap.paletteSettings.colorGradientMode !== 'Table' && this.heatMap.paletteSettings.type === 'Gradient') {
                            this.heatMap.minColorValue = !isFinite(this.heatMap.minColorValue) ?
                                this.heatMap.dataSourceMinValue : this.heatMap.minColorValue;
                            this.heatMap.maxColorValue = !isFinite(this.heatMap.maxColorValue) ?
                                this.heatMap.dataSourceMaxValue : this.heatMap.maxColorValue;
                        }
                        var tempCircleRadius = this.getRadiusBypercentage(parseFloat(this.text.toString()), heatMap.dataSourceMinValue, heatMap.dataSourceMaxValue, circleRadius);
                        this.renderBubbleCell(rectPosition, tempBorder, x, this.color, borderColor, tempCircleRadius);
                        this.updateLabelVisibleStatus((tempCircleRadius * 2) - 12, (tempCircleRadius * 2) - 6, displayText);
                    }
                    else if (cellSetting.bubbleType === 'Sector' && !ej2_base_1.isNullOrUndefined(this.text) && this.text.toString() !== '') {
                        this.renderSectorCell(rectPosition, tempBorder, x.toString(), this.color, borderColor, circleRadius, this.text);
                        this.checkLabelXDisplay = false;
                        this.checkLabelYDisplay = false;
                    }
                }
                tempRectPosition.push(rectPosition);
                if (heatMap.rangeSelection && heatMap.paletteSettings.type === 'Fixed') {
                    isValueInRange = this.isCellValueInRange(dataXIndex, dataYIndex);
                    rectPosition.visible = isValueInRange;
                }
                if (cellSetting.showLabel && this.checkLabelYDisplay && this.checkLabelXDisplay) {
                    var themeCellTextStyle = cellSetting.textStyle;
                    var options = new helper_1.TextOption(heatMap.element.id + '_HeatMapRectLabels_' + x, new helper_1.TextBasic(Math.round((tempX + tempWidth / 2) * 100) / 100, Math.round((tempY + tempHeight / 2) * 100) / 100, 'middle', displayText, null, null, 'middle'), themeCellTextStyle, themeCellTextStyle.color || this.getSaturatedColor(this.color));
                    rectPosition.textId = options.id;
                    if (heatMap.rangeSelection && heatMap.paletteSettings.type === 'Fixed') {
                        options.fill = isValueInRange ? options.fill : this.heatMap.themeStyle.toggledColor;
                    }
                    Iif (ej2_base_1.Browser.isIE && !heatMap.enableCanvasRendering) {
                        options.dy = this.heatMap.cellSettings.tileType === 'Bubble' ? '0.5ex' : '1ex';
                    }
                    this.drawSvgCanvas.createText(options, this.containerTextObject, displayText);
                }
                if (tempVal === heatMap.xLength - 1) {
                    tempY = Math.round((tempY + tempHeight) * 100) / 100;
                    tempVal = 0;
                    dataYIndex = 0;
                    if (heatMap.yAxis.opposedPosition) {
                        tempX = Math.round((heatMap.initialClipRect.x + (parseFloat(tempBorder.width.toString()) / 2)) * 100) / 100;
                    }
                    else {
                        tempX = Math.round(heatMap.initialClipRect.x * 100) / 100;
                    }
                    this.rectPositionCollection.push(tempRectPosition);
                    tempRectPosition = [];
                    dataXIndex++;
                }
                else {
                    tempX = Math.round((tempX + tempWidth) * 100) / 100;
                    tempVal++;
                    dataYIndex++;
                }
            }
            if (!ej2_base_1.isNullOrUndefined(templateElement)) {
                document.getElementById(this.heatMap.element.id + '_Secondary_Element').appendChild(templateElement);
            }
            if (!heatMap.enableCanvasRendering) {
                heatMap.svgObject.appendChild(this.containerRectObject);
                if (cellSetting.showLabel && !(cellSetting.tileType === 'Bubble' && cellSetting.bubbleType === 'Sector')) {
                    heatMap.svgObject.appendChild(this.containerTextObject);
                }
            }
        };
        Series.prototype.isCellValueInRange = function (dataXIndex, dataYIndex) {
            var isValueInRange = false;
            for (var i = 0; i < this.heatMap.toggleValue.length; i++) {
                var maxValue = void 0;
                var minValue = (i === 0) && !this.heatMap.isColorRange ? this.heatMap.dataSourceMinValue :
                    this.heatMap.isColorRange ?
                        this.heatMap.toggleValue[i].startValue : this.heatMap.toggleValue[i].value;
                if (this.heatMap.cellSettings.tileType === 'Bubble' && this.heatMap.cellSettings.bubbleType === 'SizeAndColor') {
                    maxValue = (i === this.heatMap.toggleValue.length - 1) ? this.heatMap.maxColorValue :
                        this.heatMap.toggleValue[i + 1].value - 0.01;
                }
                else {
                    maxValue = (i === this.heatMap.toggleValue.length - 1 && !this.heatMap.isColorRange) ?
                        this.heatMap.dataSourceMaxValue : this.heatMap.isColorRange ?
                        this.heatMap.toggleValue[i].endValue : this.heatMap.toggleValue[i + 1].value - 0.01;
                }
                var clonedDataSource = this.heatMap.clonedDataSource;
                var bubbleText = !ej2_base_1.isNullOrUndefined(clonedDataSource[dataXIndex][dataYIndex][1]) &&
                    clonedDataSource[dataXIndex][dataYIndex][1].toString() !== '' ? clonedDataSource[dataXIndex][dataYIndex][1] : '';
                var text = parseFloat(this.heatMap.cellSettings.tileType === 'Bubble' && this.heatMap.cellSettings.bubbleType === 'SizeAndColor' ?
                    bubbleText.toString() : this.text.toString());
                if (isNaN(text)) {
                    isValueInRange = true;
                }
                else if (!isNaN(text) && text >= minValue && text <= maxValue) {
                    if (!this.heatMap.toggleValue[i].visible) {
                        isValueInRange = false;
                        break;
                    }
                    else {
                        isValueInRange = true;
                        break;
                    }
                }
                else Iif (this.heatMap.isColorRange &&
                    maxValue >= this.heatMap.toggleValue[i].endValue && i === this.heatMap.toggleValue.length - 1) {
                    isValueInRange = true;
                    break;
                }
            }
            return isValueInRange;
        };
        Series.prototype.cellRendering = function (rectPosition, text) {
            var xAxis = this.heatMap.axisCollections[0];
            var yAxis = this.heatMap.axisCollections[1];
            var xLabels = xAxis.tooltipLabels;
            var yLabels = yAxis.tooltipLabels.slice().reverse();
            var yLabelValue = yAxis.labelValue.slice().reverse();
            var argData = {
                heatmap: this.heatMap,
                cancel: false,
                name: 'cellRender',
                value: rectPosition.value,
                xLabel: xLabels[rectPosition.xIndex].toString(),
                yLabel: yLabels[rectPosition.yIndex].toString(),
                displayText: text,
                xValue: xAxis.labelValue[rectPosition.xIndex],
                yValue: yLabelValue[rectPosition.yIndex],
                cellColor: this.color
            };
            this.heatMap.trigger('cellRender', argData);
            this.color = argData.cellColor;
            return argData.displayText;
        };
        Series.prototype.setTextAndColor = function (dataXIndex, dataYIndex) {
            this.bubbleColorValue = [];
            var adaptData = this.heatMap.dataSourceSettings;
            var clonedDataSource = this.heatMap.clonedDataSource;
            if (this.heatMap.bubbleSizeWithColor) {
                this.text = !ej2_base_1.isNullOrUndefined(clonedDataSource[dataXIndex][dataYIndex][0]) &&
                    clonedDataSource[dataXIndex][dataYIndex][0].toString() !== '' ? clonedDataSource[dataXIndex][dataYIndex][0] : '';
                this.color = !ej2_base_1.isNullOrUndefined(clonedDataSource[dataXIndex][dataYIndex][1]) &&
                    clonedDataSource[dataXIndex][dataYIndex][1].toString() !== '' ?
                    this.cellColor.getColorByValue(clonedDataSource[dataXIndex][dataYIndex][1])
                    : this.heatMap.isColorValueExist ? this.heatMap.emptyPointColor : this.cellColor.getColorByValue(this.text);
                var tempBubbleCollection = new base_1.BubbleTooltipData(adaptData.isJsonData && adaptData.adaptorType === 'Cell' ? adaptData.bubbleDataMapping.size : null, this.text, 'Size');
                this.bubbleColorValue.push(tempBubbleCollection);
                this.bubbleColorValue.push({
                    mappingName: adaptData.isJsonData && adaptData.adaptorType === 'Cell' ?
                        adaptData.bubbleDataMapping.color : null,
                    bubbleData: !ej2_base_1.isNullOrUndefined(clonedDataSource[dataXIndex][dataYIndex][1]) &&
                        clonedDataSource[dataXIndex][dataYIndex][1].toString() !== '' ? clonedDataSource[dataXIndex][dataYIndex][1] : '',
                    valueType: 'Color'
                });
            }
            else {
                this.text = clonedDataSource[dataXIndex][dataYIndex];
                this.color = this.cellColor.getColorByValue(this.text);
            }
        };
        Series.prototype.createSeriesGroup = function () {
            if (!this.heatMap.enableCanvasRendering) {
                this.containerRectObject = this.heatMap.renderer.createGroup({
                    id: this.heatMap.element.id + '_Container_RectGroup'
                });
                if (this.heatMap.cellSettings.showLabel &&
                    !(this.heatMap.cellSettings.tileType === 'Bubble' && this.heatMap.cellSettings.bubbleType === 'Sector')) {
                    this.containerTextObject = this.heatMap.renderer.createGroup({ id: this.heatMap.element.id + '_Container_TextGroup', transform: 'translate( 0, 0)' });
                }
            }
        };
        Series.prototype.updateRectDetails = function (rectPosition, tempX, tempY, tempWidth, tempHeight, text, x, dataXIndex, dataYIndex) {
            rectPosition.x = tempX;
            rectPosition.y = tempY;
            rectPosition.width = tempWidth;
            rectPosition.height = tempHeight;
            rectPosition.value = text;
            rectPosition.id = this.heatMap.element.id + '_HeatMapRect_' + x;
            rectPosition.xIndex = dataXIndex;
            rectPosition.yIndex = dataYIndex;
        };
        Series.prototype.renderTileCell = function (rectPosition, tempBorder, x, color, borderColor) {
            var rect = new helper_1.RectOption(this.heatMap.element.id + '_HeatMapRect_' + x, color, tempBorder, 1, new helper_1.Rect(rectPosition.x, rectPosition.y, rectPosition.width, rectPosition.height), borderColor || this.heatMap.themeStyle.cellBorder, tempBorder.radius, tempBorder.radius);
            this.drawSvgCanvas.drawRectangle(rect, this.containerRectObject, true);
        };
        Series.prototype.getBubbleRadius = function (width, height) {
            var radius = (width / 2) - 2;
            if (height / 2 < width / 2) {
                radius = (height / 2) - 2;
            }
            return radius < 0 ? 0 : radius;
        };
        Series.prototype.renderSectorCell = function (bubblePosition, tempBorder, x, color, borderColor, circleRadius, text) {
            var curve;
            var startAngle;
            var endAngle;
            var cX;
            var cY;
            var X1;
            var Y1;
            var tempcX;
            var tempcY;
            var pathBorderWidth;
            var centerX = Math.round((bubblePosition.x + (bubblePosition.width / 2)) * 100) / 100;
            var centerY = Math.round((bubblePosition.y + (bubblePosition.height / 2)) * 100) / 100;
            var tempColor = color;
            var sectorContibution = this.getRadiusBypercentage(text, this.heatMap.dataSourceMinValue, this.heatMap.dataSourceMaxValue, 360);
            for (var y = 0; y < 2; y++) {
                pathBorderWidth = parseFloat(tempBorder.width.toString());
                if (y === 0) {
                    curve = sectorContibution >= 180 ? 1 : 0;
                    startAngle = -90;
                    if (sectorContibution === 0) {
                        endAngle = 270;
                    }
                    else {
                        endAngle = (sectorContibution - 90);
                    }
                    cX = Math.round((centerX + circleRadius * Math.cos((sectorContibution - 90) * (Math.PI / 180))) * 100) / 100;
                    cY = Math.round((centerY + circleRadius * Math.sin((sectorContibution - 90) * (Math.PI / 180))) * 100) / 100;
                    X1 = Math.round(centerX * 100) / 100;
                    Y1 = Math.round((centerY - circleRadius) * 100) / 100;
                    if (sectorContibution === 0) {
                        tempColor = this.heatMap.emptyPointColor;
                    }
                }
                else {
                    curve = sectorContibution >= 180 ? 0 : 1;
                    startAngle = endAngle;
                    endAngle = 270;
                    tempColor = this.heatMap.emptyPointColor;
                    x = x + '_Unfilled';
                    tempcX = cX;
                    tempcY = cY;
                    cX = X1;
                    cY = Y1;
                    X1 = tempcX;
                    Y1 = tempcY;
                    if (sectorContibution === 0) {
                        pathBorderWidth = 1;
                        borderColor = color;
                    }
                }
                var path = new helper_1.Path('', false, centerX, centerY, X1, Y1, cX, cY, startAngle, endAngle, circleRadius, true);
                var sector = new helper_1.PathAttributes(this.heatMap.element.id + '_HeatMapRect_' + x, path, tempColor, tempBorder, pathBorderWidth, 1, borderColor);
                this.calculateShapes(sector, path, sectorContibution, curve);
                this.drawSvgCanvas.drawPath(sector, path, this.containerRectObject);
                if (sectorContibution === 360) {
                    break;
                }
            }
        };
        Series.prototype.calculateShapes = function (options, path, sectorContibution, curve) {
            var pathString;
            switch (sectorContibution) {
                case 360:
                case 0:
                    if (sectorContibution === 0 && path.start === path.end) {
                        pathString = 'M' + ' ' + options.x + ' ' + options.y + ' ' + 'L' + ' ' + path.x + ' ' + (path.y - path.radius);
                    }
                    else {
                        pathString = !this.heatMap.enableCanvasRendering ? 'M' + ' ' + options.x + ' ' + options.y + ' ' : '';
                        pathString = pathString + 'm' + ' ' + (-path.radius) + ' ' + '0' + ' ' +
                            'a' + ' ' + path.radius + ' ' + path.radius + ' ' + '0' + ' ' + '1' + ' ' + '0' +
                            ' ' + (path.radius * 2) + ' ' + '0' + ' ' + 'a' + ' ' + path.radius +
                            ' ' + path.radius + ' ' + '0' + ' ' + '1' + ' ' + '0' +
                            ' ' + (-(path.radius * 2)) + ' ' + '0' + ' ';
                    }
                    ej2_base_1.merge(options, { 'd': pathString });
                    break;
                default:
                    pathString = 'M' + ' ' + options.x + ' ' + options.y + ' ' + 'L' + ' ' + path.x1 + ' ' + path.y1 + ' ' +
                        'A' + ' ' + path.radius + ' ' + path.radius + ' ' + '0' + ' ' + curve + ' ' + '1' + ' ' +
                        path.cx + ' ' + path.cy + ' ' + 'Z';
                    ej2_base_1.merge(options, { 'd': pathString });
                    break;
            }
        };
        Series.prototype.renderBubbleCell = function (bubblePosition, tempBorder, x, color, borderColor, circleRadius) {
            var circle = new helper_1.CircleOption(this.heatMap.element.id + '_HeatMapRect_' + x, color, tempBorder, 1, borderColor || this.heatMap.themeStyle.cellBorder, Math.round((bubblePosition.x + (bubblePosition.width / 2)) * 100) / 100, Math.round((bubblePosition.y + (bubblePosition.height / 2)) * 100) / 100, circleRadius);
            this.drawSvgCanvas.drawCircle(circle, this.containerRectObject);
        };
        Series.prototype.updateLabelVisibleStatus = function (tempWidth, tempHeight, displayText) {
            if (this.heatMap.cellSettings.showLabel && (ej2_base_1.isNullOrUndefined(this.heatMap.cellSettings.labelTemplate) || this.heatMap.cellSettings.labelTemplate === '')) {
                this.checkLabelYDisplay = tempHeight > parseInt(this.heatMap.cellSettings.textStyle.size, 10) ? true : false;
                this.checkLabelXDisplay = tempWidth > (displayText.length *
                    (parseInt(this.heatMap.cellSettings.textStyle.size, 10) / 2)) ? true : false;
            }
        };
        Series.prototype.getRadiusBypercentage = function (text, min, max, radius) {
            var minimum = parseInt(this.heatMap.cellSettings.bubbleSize.minimum, 10);
            var maximum = parseInt(this.heatMap.cellSettings.bubbleSize.maximum, 10);
            Iif (minimum < 0 || minimum > 100 || isNaN(minimum)) {
                minimum = 0;
            }
            Iif (maximum < 0 || maximum > 100 || isNaN(maximum)) {
                maximum = 100;
            }
            var valueInPrecentage = ((text - min) /
                (max - min)) * 100;
            valueInPrecentage = isNaN(valueInPrecentage) ? 100 : valueInPrecentage;
            if ((this.heatMap.bubbleSizeWithColor ||
                (this.heatMap.cellSettings.tileType === 'Bubble' && this.heatMap.cellSettings.bubbleType === 'Size'))) {
                Iif (this.heatMap.cellSettings.isInversedBubbleSize) {
                    valueInPrecentage = 100 - valueInPrecentage;
                }
                valueInPrecentage = ((valueInPrecentage * (maximum - minimum)) / 100) + minimum;
            }
            radius = radius * (valueInPrecentage / 100);
            return (Math.round(radius * 100) / 100) < 0 ? 0 : (Math.round(radius * 100) / 100);
        };
        Series.prototype.getSaturatedColor = function (color) {
            var saturatedColor = color;
            saturatedColor = (saturatedColor === 'transparent') ? window.getComputedStyle(document.body, null).backgroundColor : saturatedColor;
            var rgbValue = helper_2.convertHexToColor(helper_2.colorNameToHex(saturatedColor));
            var contrast = Math.round((rgbValue.R * 299 + rgbValue.G * 587 + rgbValue.B * 114) / 1000);
            return contrast >= 128 ? 'black' : 'white';
        };
        Series.prototype.highlightSvgRect = function (tempID) {
            Eif (tempID.indexOf('Celltooltip') === -1) {
                if (tempID.indexOf('_HeatMapRect') !== -1) {
                    if (tempID.indexOf('_HeatMapRectLabels_') !== -1) {
                        var tempIndex = tempID.indexOf('_HeatMapRectLabels_') + 19;
                        tempID = this.heatMap.element.id + '_HeatMapRect_' + tempID.slice(tempIndex);
                    }
                    var element = document.getElementById(tempID);
                    if (this.heatMap.tempRectHoverClass !== tempID) {
                        if (this.heatMap.cellSettings.enableCellHighlighting) {
                            var oldElement = void 0;
                            if (this.heatMap.tempRectHoverClass) {
                                oldElement = document.getElementById(this.heatMap.tempRectHoverClass);
                            }
                            if (oldElement && !this.heatMap.rectSelected) {
                                oldElement.setAttribute('opacity', '1');
                            }
                            if (element && !this.heatMap.rectSelected) {
                                element.setAttribute('opacity', '0.65');
                            }
                        }
                        this.heatMap.tempRectHoverClass = tempID;
                    }
                }
                else {
                    if (this.heatMap.cellSettings.enableCellHighlighting) {
                        var oldElement = void 0;
                        if (this.heatMap.tempRectHoverClass) {
                            oldElement = document.getElementById(this.heatMap.tempRectHoverClass);
                        }
                        Iif (oldElement && !this.heatMap.rectSelected) {
                            oldElement.setAttribute('opacity', '1');
                            this.heatMap.tempRectHoverClass = '';
                        }
                    }
                }
            }
        };
        Series.prototype.getFormatedText = function (val, getFormat) {
            var format = getFormat;
            var isCustom = format.match('{value}') !== null;
            this.format = this.heatMap.intl.getNumberFormat({
                format: isCustom ? '' : format
            });
            var value = '';
            if (val.toString() !== '') {
                value = helper_2.formatValue(isCustom, format, val, this.format);
            }
            return value;
        };
        Series.prototype.getCurrentRect = function (x, y) {
            var currentRect;
            var firstRectDetails = [];
            firstRectDetails.push(this.heatMap.heatMapSeries.rectPositionCollection[0][0]);
            var rectX = Math.ceil((x - firstRectDetails[0].x) / firstRectDetails[0].width) <
                this.heatMap.axisCollections[0].axisLabelSize ?
                Math.ceil((x - firstRectDetails[0].x) / firstRectDetails[0].width) :
                this.heatMap.axisCollections[0].axisLabelSize;
            var rectY = Math.floor(((y - firstRectDetails[0].y) / firstRectDetails[0].height)) <
                this.heatMap.axisCollections[1].axisLabelSize ?
                Math.floor(((y - firstRectDetails[0].y) / firstRectDetails[0].height)) :
                this.heatMap.axisCollections[1].axisLabelSize - 1;
            rectX = rectX === 0 ? 1 : rectX;
            currentRect = this.heatMap.heatMapSeries.rectPositionCollection[rectY][rectX - 1];
            this.hoverXAxisLabel = this.heatMap.axisCollections[0].tooltipLabels[rectX - 1];
            this.hoverXAxisValue = this.heatMap.axisCollections[0].labelValue[rectX - 1];
            this.hoverYAxisLabel = this.heatMap.axisCollections[1].tooltipLabels[(this.heatMap.axisCollections[1].tooltipLabels.length - 1) - rectY];
            this.hoverYAxisValue = this.heatMap.axisCollections[1].labelValue[(this.heatMap.axisCollections[1].labelValue.length - 1) - rectY];
            return currentRect;
        };
        Series.prototype.destroy = function () {
            Eif (!ej2_base_1.isNullOrUndefined(this.cellColor)) {
                this.cellColor.destroy();
            }
            this.cellColor = null;
            this.bubbleColorValue = null;
            this.containerRectObject = null;
            this.containerTextObject = null;
            this.drawSvgCanvas = null;
            this.format = null;
            this.hoverXAxisValue = null;
            this.hoverYAxisValue = null;
            this.rectPositionCollection = null;
            this.heatMap = null;
        };
        return Series;
    }());
    exports.Series = Series;
});