all files / chart/axis/ polar-radar-panel.js

99.77% Statements 428/429
92.31% Branches 264/286
100% Functions 30/30
99.77% Lines 425/426
11 statements, 6 functions, 9 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          200× 200× 200×   211× 211× 211× 211× 211× 211×   211× 211× 211×   211× 211× 211×   422× 422× 422× 422×     211× 211× 211× 211× 211× 211×   211× 211× 211× 211× 211× 211× 211× 211× 211× 211× 211×   200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200×   422× 422× 422× 422× 422×   422× 422× 422× 422× 422×   211× 211× 211× 211× 211× 211× 422× 422× 422× 211× 209×   211× 210×       211× 211× 209×   211× 210×     422× 422×     211× 211×   211× 211×   209× 209× 209× 209×   209×             209× 209× 209× 209×     210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 1824× 1824× 1824× 1824× 1824×   1824×   1824× 1824× 1824× 262× 1871× 1871× 208× 208× 208×     1663×     262× 208×   54× 1722× 1722×       1616×   1610× 1610× 1610×   210× 210×     211× 211× 211× 211× 211× 211× 211× 211× 211× 211× 211× 211×       211× 211× 211× 211× 209× 177× 1542× 1542× 1542× 1542×   1542× 1542×   177×       32× 272× 272× 272× 272× 272× 272×   32×       211× 209× 209× 1814× 1814× 1814× 1814× 1814× 1814× 1814×       278× 278× 278× 278× 278× 278× 278× 5518× 5518× 5240×     278×   5518× 5518× 5518× 5518× 5518×   278×   209× 209× 209× 209× 209× 209× 209× 209× 209× 209× 209× 209× 209× 209× 2681× 2681× 2681× 2681× 2681× 2681× 2681× 2681× 2681×   76× 76× 76×   2681× 2681×     76× 76× 76× 76× 76× 76× 76× 152×   152× 136× 136× 136× 136× 136× 136×   136×       76× 76× 76×   210× 210× 210× 72×   210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 210× 2692× 2692× 2692× 2692× 2692× 2692×     2692× 2692× 2692× 2022× 2022× 2022× 2022× 2022× 2022× 2022× 3138× 3138× 3138×       2022× 2022× 2022× 2022×       2692× 2692× 210×   2482× 132× 132× 132×   2692× 714× 12504× 12504× 342× 342× 342×     12162×       2692× 1211× 1211× 10× 10× 10× 10×       2692× 2692× 342×   2350× 2350×   210× 210×     10× 10× 10× 10× 10× 10×           10×   4516× 2183×   2333× 1171×   4516× 4516×   4495× 4495× 4495× 4495× 4495× 4495× 4495× 4495× 4495× 4495× 4495×   4495× 4434× 4434× 4434× 4434× 4434× 4434×     2681× 2681× 2681× 2681× 2681× 2673× 2673× 2673× 2673×   2681× 2620× 2620× 2620× 2620×     9138× 9138×          
/* 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 __());
    };
})();
define(["require", "exports", "../../common/utils/helper", "../../common/utils/helper", "../../common/utils/helper", "@syncfusion/ej2-svg-base", "../series/line-base", "../../common/utils/helper"], function (require, exports, helper_1, helper_2, helper_3, ej2_svg_base_1, line_base_1, helper_4) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PolarRadarPanel = (function (_super) {
        __extends(PolarRadarPanel, _super);
        function PolarRadarPanel() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.visibleAxisLabelRect = [];
            return _this;
        }
        PolarRadarPanel.prototype.measureAxis = function (rect) {
            var chart = this.chart;
            this.initialClipRect = rect;
            this.seriesClipRect = new ej2_svg_base_1.Rect(rect.x, rect.y, rect.width, rect.height);
            this.measureRowAxis(chart, this.initialClipRect);
            this.measureColumnAxis(chart, this.initialClipRect);
            this.calculateAxisSize();
        };
        PolarRadarPanel.prototype.measureRowAxis = function (chart, rect) {
            this.calculateRowSize(rect);
            var row = chart.rows[0];
            this.measureDefinition(row, chart, new ej2_svg_base_1.Size(chart.availableSize.width, row.computedHeight));
        };
        PolarRadarPanel.prototype.measureColumnAxis = function (chart, rect) {
            this.calculateColumnSize(rect);
            var column = chart.columns[0];
            this.measureDefinition(column, chart, new ej2_svg_base_1.Size(column.computedWidth, chart.availableSize.height));
        };
        PolarRadarPanel.prototype.measureDefinition = function (definition, chart, size) {
            for (var _i = 0, _a = definition.axes; _i < _a.length; _i++) {
                var axis = _a[_i];
                axis.getModule(chart);
                axis.baseModule.calculateRangeAndInterval(size, axis);
            }
        };
        PolarRadarPanel.prototype.calculateAxisSize = function () {
            var chart = this.chart;
            var axis;
            var padding = 5;
            this.centerX = this.initialClipRect.width * 0.5 + this.initialClipRect.x;
            this.centerY = this.initialClipRect.height * 0.5 + this.initialClipRect.y;
            chart.radius = Math.min(this.initialClipRect.width, this.initialClipRect.height) / 2 - padding -
                chart.primaryXAxis.majorTickLines.height - chart.primaryXAxis.maxLabelSize.height;
            chart.radius = (chart.primaryXAxis.coefficient * chart.radius) / 100;
            this.seriesClipRect.y = this.centerY - chart.radius;
            this.seriesClipRect.x = this.centerX - chart.radius;
            this.seriesClipRect.height = 2 * chart.radius;
            this.seriesClipRect.width = 2 * chart.radius;
            this.calculateRowSize(this.seriesClipRect);
            axis = chart.primaryYAxis;
            axis.rect = this.seriesClipRect;
            this.calculateColumnSize(this.seriesClipRect);
            axis = chart.primaryXAxis;
            axis.rect = this.seriesClipRect;
        };
        PolarRadarPanel.prototype.measure = function () {
            var chart = this.chart;
            var yAxis = chart.primaryYAxis;
            yAxis.isRTLEnabled = chart.enableRtl;
            yAxis.setIsInversedAndOpposedPosition(true);
            chart.verticalAxes.push(yAxis);
            var row = chart.rows[0];
            row.axes[0] = yAxis;
            chart.rows[0] = row;
            var xAxis = chart.primaryXAxis;
            xAxis.isRTLEnabled = chart.enableRtl;
            xAxis.setIsInversedAndOpposedPosition(true);
            chart.horizontalAxes.push(xAxis);
            var column = chart.columns[0];
            column.axes[0] = xAxis;
            chart.columns[0] = column;
        };
        PolarRadarPanel.prototype.calculateRowSize = function (rect) {
            var chart = this.chart;
            var row = chart.rows[0];
            row.computedHeight = rect.height / 2;
            row.computedTop = rect.y;
            chart.rows[0] = row;
        };
        PolarRadarPanel.prototype.calculateColumnSize = function (rect) {
            var chart = this.chart;
            var column = chart.columns[0];
            column.computedLeft = rect.x;
            column.computedWidth = rect.width;
            chart.columns[0] = column;
        };
        PolarRadarPanel.prototype.renderAxes = function () {
            var axis;
            var chart = this.chart;
            this.startAngle = chart.primaryXAxis.startAngle;
            var axisElement = chart.renderer.createGroup({ id: chart.element.id + 'AxisCollection' });
            var axisLineElement = chart.renderer.createGroup({ id: chart.element.id + 'AxisOutsideCollection' });
            for (var i = 0, len = chart.axisCollections.length; i < len; i++) {
                this.element = chart.renderer.createGroup({ id: chart.element.id + 'AxisGroup' + i });
                axis = chart.axisCollections[i];
                if (axis.orientation === 'Horizontal') {
                    if (axis.majorGridLines.width > 0 || axis.majorTickLines.width > 0) {
                        this.drawXAxisGridLine(axis, i);
                    }
                    if (axis.visible && axis.internalVisibility) {
                        this.drawXAxisLabels(axis, i);
                    }
                }
                else {
                    this.drawYAxisGridLine(axis, i);
                    if (axis.lineStyle.width > 0) {
                        this.drawYAxisLine(axis, i);
                    }
                    if (axis.visible && axis.internalVisibility) {
                        this.drawYAxisLabels(axis, i);
                    }
                }
                Eif (!this.chart.enableCanvas) {
                    axisElement.appendChild(this.element);
                }
            }
            Eif (!this.chart.enableCanvas) {
                axisElement.appendChild(this.element);
            }
            helper_2.appendChildElement(chart.enableCanvas, chart.svgObject, axisElement, chart.redraw);
            return axisLineElement;
        };
        PolarRadarPanel.prototype.drawYAxisLine = function (axis, index) {
            var chart = this.chart;
            var optionsLine = {};
            var vector = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(axis.visibleLabels[0].value, axis), this.startAngle);
            var axisLine = 'M ' + this.centerX + ' ' + this.centerY + 'L ' +
                (this.centerX + chart.radius * vector.x) + ' ' + (this.centerY + chart.radius * vector.y);
            optionsLine = {
                'id': chart.element.id + 'AxisLine_' + index,
                'd': axisLine,
                'stroke-dasharray': axis.lineStyle.dashArray,
                'stroke-width': axis.lineStyle.width,
                'stroke': axis.lineStyle.color || chart.themeStyle.axisLine
            };
            var element = chart.renderer.drawPath(optionsLine);
            this.setPointerEventNone(element);
            Eif (!this.chart.enableCanvas) {
                chart.yAxisElements.appendChild(element);
            }
        };
        PolarRadarPanel.prototype.drawYAxisLabels = function (axis, index) {
            var chart = this.chart;
            var elementSize;
            var options;
            var pointX = 0;
            var pointY = 0;
            var angle = this.startAngle < 0 ? this.startAngle + 360 : this.startAngle;
            var anchor = 'middle';
            var radius;
            var padding = 5;
            var isIntersect;
            var labelRegions = [];
            var isLabelVisible = [];
            isLabelVisible[0] = true;
            var intersectType = axis.labelIntersectAction;
            var labelElement = chart.renderer.createGroup({ id: chart.element.id + 'AxisLabels' + index });
            var vector = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(axis.visibleLabels[0].value, axis), this.startAngle);
            for (var i = 0, len = axis.visibleLabels.length; i < len; i++) {
                isIntersect = false;
                radius = chart.radius * helper_1.valueToCoefficient(axis.visibleLabels[i].value, axis);
                elementSize = axis.visibleLabels[i].size;
                radius = chart.radius * helper_1.valueToCoefficient(axis.visibleLabels[i].value, axis);
                pointX = (this.centerX + radius * vector.x) + ((axis.majorTickLines.height + elementSize.width / 2 + padding / 2)
                    * (Math.cos(angle * Math.PI / 180)) * (axis.labelPosition === 'Inside' && chart.enableRtl ? -1 : axis.labelPosition === 'Inside' ? 1 : axis.labelPosition === 'Outside' && chart.enableRtl ? 1 : -1));
                pointY = (this.centerY + radius * vector.y) + ((axis.majorTickLines.height + elementSize.height / 2)
                    * (Math.sin(angle * Math.PI / 180)) * (axis.labelPosition === 'Inside' && chart.enableRtl ? -1 : axis.labelPosition === 'Inside' ? 1 : axis.labelPosition === 'Outside' && chart.enableRtl ? 1 : -1));
                pointY += (elementSize.height / 4);
                labelRegions[i] = this.getLabelRegion(pointX, pointY, axis.visibleLabels[i], anchor);
                if (i !== 0 && intersectType === 'Hide') {
                    for (var j = i; j >= 0; j--) {
                        j = (j === 0) ? 0 : (j === i) ? (j - 1) : j;
                        if (isLabelVisible[j] && helper_1.isOverlap(labelRegions[i], labelRegions[j])) {
                            isIntersect = true;
                            isLabelVisible[i] = false;
                            break;
                        }
                        else {
                            isLabelVisible[i] = true;
                        }
                    }
                    if (isIntersect) {
                        continue;
                    }
                    for (var _i = 0, _a = this.visibleAxisLabelRect; _i < _a.length; _i++) {
                        var rect = _a[_i];
                        if (helper_1.isOverlap(labelRegions[i], rect)) {
                            isIntersect = true;
                            break;
                        }
                    }
                }
                if (isIntersect) {
                    continue;
                }
                this.visibleAxisLabelRect.push(labelRegions[i]);
                options = new ej2_svg_base_1.TextOption(chart.element.id + index + '_AxisLabel_' + i, pointX, pointY, anchor, axis.visibleLabels[i].text);
                helper_4.textElement(chart.renderer, options, axis.labelStyle, axis.labelStyle.color || chart.themeStyle.axisLabelFont.color, labelElement, false, chart.redraw, true, true, null, null, null, null, chart.enableCanvas, null, chart.themeStyle.axisLabelFont);
            }
            Eif (!this.chart.enableCanvas) {
                chart.yAxisElements.appendChild(labelElement);
            }
        };
        PolarRadarPanel.prototype.drawYAxisGridLine = function (axis, index) {
            var chart = this.chart;
            var options;
            var radius;
            var majorTick = '';
            var majorGrid = '';
            var vector;
            var angle = this.startAngle < 0 ? this.startAngle + 360 : this.startAngle;
            var x1;
            var y1;
            var x2;
            var y2;
            var border = {
                color: axis.majorGridLines.color || chart.themeStyle.majorGridLine,
                width: axis.majorGridLines.width
            };
            var previousValue;
            var element;
            var inversedRadius;
            if (axis.majorGridLines.width > 0) {
                if (chart.visibleSeries[0].type === 'Polar') {
                    for (var j = 0; j < axis.visibleLabels.length; j++) {
                        element = helper_4.getElement(chart.element.id + '_MajorGridLine_' + index + '_' + j);
                        previousValue = element ? element.getAttribute('r') : null;
                        radius = chart.radius * helper_1.valueToCoefficient(axis.visibleLabels[j].value, axis);
                        if (axis.isInversed && !inversedRadius) {
                            inversedRadius = radius;
                        }
                        options = new helper_3.CircleOption(chart.element.id + '_MajorGridLine_' + index + '_' + j, 'transparent', border, axis.majorGridLines.width, this.centerX, this.centerY, radius);
                        helper_2.appendChildElement(chart.enableCanvas, this.element, chart.renderer.drawCircle(options), chart.redraw, true, 'r', 'r', new helper_4.ChartLocation(+previousValue, +previousValue), null, true);
                    }
                    if (radius !== chart.radius && (!axis.isInversed || inversedRadius !== chart.radius)) {
                        options = new helper_3.CircleOption(chart.element.id + '_MajorGridLine_' + index + '_' + axis.visibleLabels.length + 1, 'transparent', border, axis.majorGridLines.width, this.centerX, this.centerY, chart.radius);
                        helper_2.appendChildElement(chart.enableCanvas, this.element, chart.renderer.drawCircle(options), chart.redraw, true, 'r', 'r', new helper_4.ChartLocation(+previousValue, +previousValue), null, true);
                    }
                }
                else {
                    for (var j = 0; j < axis.visibleLabels.length; j++) {
                        radius = chart.radius * helper_1.valueToCoefficient(axis.visibleLabels[j].value, axis);
                        majorGrid = this.renderRadarGrid(radius, '', chart);
                        element = helper_4.getElement(chart.element.id + '_MajorGridLine_' + index + '_' + j);
                        previousValue = element ? element.getAttribute('d') : null;
                        options = new ej2_svg_base_1.PathOption(chart.element.id + '_MajorGridLine_' + index + '_' + j, 'transparent', axis.majorGridLines.width, axis.majorGridLines.color || chart.themeStyle.majorGridLine, null, null, majorGrid);
                        helper_2.appendChildElement(chart.enableCanvas, this.element, chart.renderer.drawPath(options), chart.redraw, true, 'x', 'y', null, previousValue, true);
                    }
                    if (radius !== chart.radius) {
                        majorGrid = this.renderRadarGrid(chart.radius, '', chart);
                        element = helper_4.getElement(chart.element.id + '_MajorGridLine_' + index + '_' + axis.visibleLabels.length);
                        previousValue = element ? element.getAttribute('d') : null;
                        options = new ej2_svg_base_1.PathOption(chart.element.id + '_MajorGridLine_' + index + '_' + axis.visibleLabels.length, 'transparent', axis.majorGridLines.width, axis.majorGridLines.color || chart.themeStyle.majorGridLine, null, null, majorGrid);
                        helper_2.appendChildElement(chart.enableCanvas, this.element, chart.renderer.drawPath(options), chart.redraw, true, 'x', 'y', null, previousValue, true);
                    }
                }
            }
            if (axis.majorTickLines.width > 0) {
                vector = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(axis.visibleLabels[0].value, axis), this.startAngle);
                for (var i = 0; i < axis.visibleLabels.length; i++) {
                    radius = chart.radius * helper_1.valueToCoefficient(axis.visibleLabels[i].value, axis);
                    x1 = this.centerX + radius * vector.x;
                    y1 = this.centerY + radius * vector.y;
                    x2 = x1 + (axis.majorTickLines.height * (Math.cos(angle * Math.PI / 180)) * (axis.tickPosition === 'Inside' && chart.enableRtl ? -1 : axis.tickPosition === 'Inside' ? 1 : axis.tickPosition === 'Outside' && chart.enableRtl ? 1 : -1));
                    y2 = y1 + (axis.majorTickLines.height * (Math.sin(angle * Math.PI / 180)) * (axis.tickPosition === 'Inside' && chart.enableRtl ? -1 : axis.tickPosition === 'Inside' ? 1 : axis.tickPosition === 'Outside' && chart.enableRtl ? 1 : -1));
                    majorTick = 'M ' + x1 + ' ' + y1 + ' L ' + x2 + ' ' + y2;
                    this.renderTickLine(axis, index, majorTick, '', i);
                }
            }
        };
        PolarRadarPanel.prototype.renderRadarGrid = function (radius, majorGrid, chart) {
            var vector;
            var vector2;
            var x1;
            var y1;
            var x2;
            var y2;
            for (var i = 0, len = chart.primaryXAxis.visibleLabels.length; i < len; i++) {
                vector = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(chart.primaryXAxis.visibleLabels[i].value, chart.primaryXAxis), this.startAngle);
                if (i + 1 < len) {
                    vector2 = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(chart.primaryXAxis.visibleLabels[i + 1].value, chart.primaryXAxis), this.startAngle);
                }
                else {
                    vector2 = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(chart.primaryXAxis.visibleLabels[0].value, chart.primaryXAxis), this.startAngle);
                }
                x1 = this.centerX + radius * vector.x;
                y1 = this.centerY + radius * vector.y;
                x2 = this.centerX + radius * vector2.x;
                y2 = this.centerY + radius * vector2.y;
                majorGrid = majorGrid.concat((i ? 'L ' : 'M ') + x1 + ' ' + y1 + ' ' + 'L ' + x2 + ' ' + y2 + ' ');
            }
            return majorGrid;
        };
        PolarRadarPanel.prototype.drawXAxisGridLine = function (axis, index) {
            var chart = this.chart;
            var tempInterval;
            var vector;
            var majorGrid = '';
            var majorTick = '';
            var minorGirdLine = '';
            var minorTickLine = '';
            var x1 = this.centerX;
            var x2;
            var y1 = this.centerY;
            var y2;
            var minorDirection;
            var length = axis.visibleLabels.length;
            for (var i = 0; i < length; i++) {
                tempInterval = axis.visibleLabels[i].value;
                vector = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(axis.visibleLabels[i].value, axis), this.startAngle);
                x2 = this.centerX + chart.radius * vector.x;
                y2 = this.centerY + chart.radius * vector.y;
                var xLoc = x2 + (axis.majorTickLines.height * vector.x * (axis.tickPosition === 'Inside' ? -1 : 1));
                var yLoc = y2 + (axis.majorTickLines.height * vector.y * (axis.tickPosition === 'Inside' ? -1 : 1));
                majorGrid = 'M ' + x1 + ' ' + y1 + ' ' + 'L ' + x2 + ' ' + y2;
                majorTick = 'M ' + x2 + ' ' + y2 + ' L ' + xLoc + ' ' + yLoc;
                if (axis.minorTicksPerInterval > 0 && (axis.minorGridLines.width > 0 || axis.minorTickLines.width > 0)
                    && axis.valueType !== 'Category' && chart.visibleSeries[0].type !== 'Radar') {
                    minorDirection = this.drawAxisMinorLine(axis, tempInterval, minorGirdLine, minorTickLine);
                    minorGirdLine = minorDirection[0];
                    minorTickLine = minorDirection[1];
                }
                this.renderTickLine(axis, index, majorTick, minorTickLine, i);
                this.renderGridLine(axis, index, majorGrid, minorGirdLine, i);
            }
        };
        PolarRadarPanel.prototype.drawAxisMinorLine = function (axis, tempInterval, minorGird, minorTick) {
            var value = tempInterval;
            var x;
            var y;
            var vector;
            var range = axis.visibleRange;
            var direction = [];
            for (var j = 0; j < axis.minorTicksPerInterval; j++) {
                value += (axis.valueType === 'DateTime' ? axis.dateTimeInterval : axis.visibleRange.interval) /
                    (axis.minorTicksPerInterval + 1);
                if (helper_1.inside(value, range)) {
                    vector = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(value, axis), this.startAngle);
                    x = this.centerX + this.chart.radius * vector.x;
                    y = this.centerY + this.chart.radius * vector.y;
                    var tickXSize = x + (axis.minorTickLines.height * vector.x * (axis.tickPosition === 'Inside' ? -1 : 1));
                    var tickYSize = y + (axis.minorTickLines.height * vector.y * (axis.tickPosition === 'Inside' ? -1 : 1));
                    minorGird = minorGird.concat('M' + ' ' + this.centerX + ' ' + this.centerY
                        + 'L ' + x + ' ' + y);
                    minorTick = minorTick.concat('M' + ' ' + x + ' ' + y + 'L' + ' ' + (tickXSize) + ' ' +
                        (tickYSize));
                }
            }
            direction.push(minorGird);
            direction.push(minorTick);
            return direction;
        };
        PolarRadarPanel.prototype.drawXAxisLabels = function (axis, index) {
            this.visibleAxisLabelRect = [];
            var legendRect;
            if (this.chart.legendModule) {
                legendRect = this.chart.legendModule.legendBounds;
            }
            var chart = this.chart;
            var pointX = 0;
            var pointY = 0;
            var labelElement = chart.renderer.createGroup({ id: chart.element.id + 'AxisLabels' + index });
            var options;
            var vector;
            var labelText;
            var firstLabelX;
            var islabelInside = axis.labelPosition === 'Inside';
            var padding = 5;
            var lastLabelX;
            var label;
            var textAnchor = '';
            var isIntersect;
            var labelRegions = [];
            var isLabelVisible = [];
            isLabelVisible[0] = true;
            var intersectType = axis.labelIntersectAction;
            var ticksbwtLabel = axis.valueType === 'Category' && axis.labelPlacement === 'BetweenTicks' ? 0.5 : 0;
            var radius = chart.radius + axis.majorTickLines.height;
            radius = (islabelInside) ? -radius : radius;
            for (var i = 0, len = axis.visibleLabels.length; i < len; i++) {
                isIntersect = false;
                vector = helper_4.CoefficientToVector(helper_4.valueToPolarCoefficient(axis.visibleLabels[i].value + ticksbwtLabel, axis), this.startAngle);
                Eif (!isNaN(vector.x) && !isNaN(vector.y)) {
                    pointX = this.centerX + (radius + axis.majorTickLines.height + padding) * vector.x;
                    pointY = this.centerY + (radius + axis.majorTickLines.height + padding) * vector.y;
                    textAnchor = parseFloat(pointX.toFixed(1)) === parseFloat(this.centerX.toFixed(1)) ? 'middle' :
                        ((pointX < this.centerX && !islabelInside) || (pointX > this.centerX && islabelInside)) ? 'end' : 'start';
                }
                label = axis.visibleLabels[i];
                labelText = label.text;
                if (axis.enableTrim || intersectType === 'Trim') {
                    var originalText = axis.visibleLabels[i].originalText;
                    var trimText = void 0;
                    var size = void 0;
                    var labelPosition = axis.labelPosition;
                    var chartWidth = chart.availableSize.width;
                    var textLength = originalText.length;
                    for (var i_1 = textLength - 1; i_1 >= 0; --i_1) {
                        trimText = originalText.substring(0, i_1) + '...';
                        size = ej2_svg_base_1.measureText(trimText, axis.labelStyle, this.chart.themeStyle.axisLabelFont).width;
                        if (pointX === chartWidth / 2 ? (pointX - size / 2 >= 0 && pointX + size / 2 <= chartWidth) :
                            ((labelPosition === 'Outside' && ((pointX >= chartWidth / 2 && pointX + size <= chartWidth) ||
                                (pointX <= chartWidth / 2 && pointX - size >= 0))) || (labelPosition === 'Inside' &&
                                (pointX + size <= chartWidth / 2 || pointX - size >= chartWidth / 2)))) {
                            labelText = i_1 === textLength - 1 ? originalText : trimText;
                            label.size.width = ej2_svg_base_1.measureText(labelText, axis.labelStyle, this.chart.themeStyle.axisLabelFont).width;
                            label.text = labelText;
                            break;
                        }
                    }
                }
                labelRegions[i] = this.getLabelRegion(pointX, pointY, label, textAnchor);
                if (i === 0) {
                    firstLabelX = pointX;
                }
                else if (i === axis.visibleLabels.length - 1 && axis.valueType !== 'Category') {
                    lastLabelX = ej2_svg_base_1.measureText(labelText, axis.labelStyle, this.chart.themeStyle.axisLabelFont).height;
                    lastLabelX += pointX;
                    labelText = (lastLabelX > firstLabelX) ? '' : labelText;
                }
                if (i !== 0 && intersectType === 'Hide') {
                    for (var j = i; j >= 0; j--) {
                        j = (j === 0) ? 0 : ((j === i) ? (j - 1) : j);
                        if (isLabelVisible[j] && helper_1.isOverlap(labelRegions[i], labelRegions[j])) {
                            isIntersect = true;
                            isLabelVisible[i] = false;
                            break;
                        }
                        else {
                            isLabelVisible[i] = true;
                        }
                    }
                }
                if (!isIntersect && legendRect) {
                    isIntersect = helper_1.isOverlap(labelRegions[i], legendRect);
                    if (isIntersect) {
                        var width = this.getAvailableSpaceToTrim(legendRect, labelRegions[i]);
                        Eif (width > 0) {
                            labelText = helper_1.textTrim(width, axis.visibleLabels[i].originalText, axis.labelStyle, this.chart.enableRtl, this.chart.themeStyle.axisLabelFont);
                            isIntersect = false;
                        }
                    }
                }
                options = new ej2_svg_base_1.TextOption(chart.element.id + index + '_AxisLabel_' + i, pointX, pointY, !chart.enableRtl ? textAnchor : textAnchor === 'end' ? 'start' : textAnchor === 'start' ? 'end' : textAnchor, labelText, '', 'central');
                if (isIntersect) {
                    continue;
                }
                this.visibleAxisLabelRect.push(labelRegions[i]);
                helper_4.textElement(chart.renderer, options, label.labelStyle, label.labelStyle.color || chart.themeStyle.axisLabelFont.color, labelElement, false, chart.redraw, true, true, null, null, null, null, chart.enableCanvas, null, chart.themeStyle.axisLabelFont);
            }
            Eif (!this.chart.enableCanvas) {
                this.element.appendChild(labelElement);
            }
        };
        PolarRadarPanel.prototype.getAvailableSpaceToTrim = function (legendRect, labelRect) {
            var legendX1 = legendRect.x;
            var legendX2 = legendX1 + legendRect.width;
            var labelX1 = labelRect.x;
            var labelX2 = labelX1 + labelRect.width;
            var width = 0;
            if (labelX1 > legendX1 && labelX1 < legendX2 && labelX2 > legendX2) {
                width = labelX2 - legendX2;
            }
            else Iif (labelX1 > legendX1 && labelX1 < legendX2 && labelX2 < legendX2) {
                width = 0;
            }
            else if (labelX2 > legendX1 && labelX2 < legendX2 && labelX1 < legendX1) {
                width = legendX1 - labelX1;
            }
            else Eif (labelX2 > legendX1 && labelX2 > legendX2 && labelX1 < legendX1) {
                width = legendX1 - labelX1;
            }
            return width;
        };
        PolarRadarPanel.prototype.getLabelRegion = function (pointX, pointY, label, anchor) {
            if (anchor === 'middle') {
                pointX -= (label.size.width / 2);
            }
            else if (anchor === 'end') {
                pointX -= label.size.width;
            }
            pointY -= (label.size.height / 2);
            return new ej2_svg_base_1.Rect(pointX, pointY, label.size.width, label.size.height);
        };
        PolarRadarPanel.prototype.renderTickLine = function (axis, index, majorTickLine, minorTickLine, gridIndex) {
            var tickOptions;
            var chart = this.chart;
            var direction;
            var element;
            Eif (axis.majorTickLines.width > 0) {
                element = helper_4.getElement(chart.element.id + '_MajorTickLine_' + index + '_' + gridIndex);
                direction = element ? element.getAttribute('d') : null;
                tickOptions = new ej2_svg_base_1.PathOption(chart.element.id + '_MajorTickLine_' + index + '_' + gridIndex, 'transparent', axis.majorTickLines.width, axis.majorTickLines.color || chart.themeStyle.majorTickLine, null, null, majorTickLine);
                element = chart.renderer.drawPath(tickOptions);
                this.setPointerEventNone(element);
                helper_2.appendChildElement(chart.enableCanvas, chart.yAxisElements, element, chart.redraw, true, 'x', 'y', null, direction);
            }
            if (axis.minorTickLines.width > 0) {
                element = helper_4.getElement(chart.element.id + '_MinorTickLine_' + index + '_' + gridIndex);
                direction = element ? element.getAttribute('d') : null;
                tickOptions = new ej2_svg_base_1.PathOption(chart.element.id + '_MinorTickLine_' + index + '_' + gridIndex, 'transparent', axis.minorTickLines.width, axis.minorTickLines.color || chart.themeStyle.minorTickLine, null, null, minorTickLine);
                element = chart.renderer.drawPath(tickOptions);
                this.setPointerEventNone(element);
                helper_2.appendChildElement(chart.enableCanvas, chart.yAxisElements, element, chart.redraw, true, 'x', 'y', null, direction);
            }
        };
        PolarRadarPanel.prototype.renderGridLine = function (axis, index, majorGrid, minorGird, gridIndex) {
            var chart = this.chart;
            var gridOptions;
            var direction;
            var element;
            if (axis.majorGridLines.width > 0) {
                element = helper_4.getElement(chart.element.id + '_MajorGridLine_' + index + '_' + gridIndex);
                direction = element ? element.getAttribute('d') : null;
                gridOptions = new ej2_svg_base_1.PathOption(chart.element.id + '_MajorGridLine_' + index + '_' + gridIndex, 'transparent', axis.majorGridLines.width, axis.majorGridLines.color || chart.themeStyle.majorGridLine, null, axis.majorGridLines.dashArray, majorGrid);
                helper_2.appendChildElement(chart.enableCanvas, this.element, chart.renderer.drawPath(gridOptions), chart.redraw, true, 'x', 'y', null, direction);
            }
            if (axis.minorGridLines.width > 0) {
                element = helper_4.getElement(chart.element.id + '_MinorGridLine_' + index + '_' + gridIndex);
                direction = element ? element.getAttribute('d') : null;
                gridOptions = new ej2_svg_base_1.PathOption(chart.element.id + '_MinorGridLine_' + index + '_' + gridIndex, 'transparent', axis.minorGridLines.width, axis.minorGridLines.color || chart.themeStyle.minorGridLine, null, axis.minorGridLines.dashArray, minorGird);
                helper_2.appendChildElement(chart.enableCanvas, this.element, chart.renderer.drawPath(gridOptions), chart.redraw, true, 'x', 'y', null, direction);
            }
        };
        PolarRadarPanel.prototype.setPointerEventNone = function (element) {
            Eif (element) {
                element.style.pointerEvents = 'none';
            }
        };
        return PolarRadarPanel;
    }(line_base_1.LineBase));
    exports.PolarRadarPanel = PolarRadarPanel;
});