all files / chart3d/utils/ renderer.js

97.2% Statements 347/357
85.67% Branches 251/293
100% Functions 19/19
97.2% Lines 347/357
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     763× 763× 1610× 1610× 1610× 835× 750×     85×       775× 761×     14×         14× 14× 14× 14× 14×         14× 14× 14× 14× 84×     85× 85× 85× 85× 85× 85× 85× 510×     763× 763× 763× 763×   750× 750× 750× 750× 750× 750× 750× 4500×     761× 761× 761× 761× 761× 761× 4566×         1610× 1466×   1610×   1610× 1606× 1606×     1606× 660×               660× 660× 660× 660× 660× 660× 660× 660× 660× 660× 660× 660× 294× 294× 294× 69×     225×   294× 294×             294× 294× 294× 294× 294× 294×     366× 366× 366× 64×     302×   366×     366× 366×             366× 366× 366× 366× 366×       6186× 6186× 6186× 6186× 6186× 42× 42× 42×           6180×     15× 15× 15× 15× 15×           1606× 1606× 1606× 1606× 1606× 1606× 1606× 1606× 1606× 13123× 13123× 13123× 13123× 13123× 13123× 13123× 13123× 13123× 13123× 13123× 6455× 6455×   6455×     6668× 6668× 6668×         6668×   6668×   6668×   13123× 13123× 13123× 13123×                         13123× 6455× 238× 238× 238×     6217× 6186×   31× 10× 10×   21×     15× 10×               13119×               13119×       13119× 13119× 13119×       92× 92×             92× 92× 92× 92× 92× 92× 92× 92× 44×     48×   92× 92× 92× 92× 92× 63× 63× 252× 252× 252× 120×     132×   252× 252× 252× 252×         344× 344× 344× 344× 344× 164× 164× 164× 164× 164× 164×     180× 180× 180× 180× 180× 180×   344×   1466×     1466× 1466× 1466× 1466× 1466× 1466× 1466× 1466× 1466× 1466× 1466× 1466× 1466× 697× 697× 5841× 5776×       65×     5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 5841× 185× 185× 275× 275× 275× 275× 275× 275× 275× 275× 275× 275× 275× 275× 275×           769× 6264×   6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 6264× 33× 33× 132× 132× 132× 132× 132× 132× 132× 132× 132× 132× 132× 132× 132× 132×                
define(["require", "exports", "@syncfusion/ej2-svg-base", "../../common/utils/helper", "@syncfusion/ej2-base", "./chart3dRender"], function (require, exports, ej2_svg_base_1, helper_1, ej2_base_1, chart3dRender_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var WallRenderer = (function () {
        function WallRenderer() {
        }
        WallRenderer.prototype.update3DWall = function (chart) {
            this.updateBackWall(chart);
            for (var i = 0; i < chart.axisCollections.length; i++) {
                var axis = chart.axisCollections[i];
                var opposedPosition = axis.opposedPosition || axis.isAxisOpposedPosition;
                if (axis.orientation.toLowerCase() === 'vertical') {
                    if (!opposedPosition) {
                        this.updateLeftWall(chart);
                    }
                    else {
                        this.updateRightWall(chart);
                    }
                }
                else {
                    if (!opposedPosition) {
                        this.updateBottomWall(chart);
                    }
                    else {
                        this.updateTopWall(chart);
                    }
                }
            }
        };
        WallRenderer.prototype.updateTopWall = function (chart) {
            var offset = 0;
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var y = areaBounds.y;
            Eif (chart.wallSize < y) {
                offset = y - chart.wallSize;
            }
            else {
                offset = -(chart.wallSize - y);
            }
            var topLeftFrontVector = chart.vector.vector3D(areaBounds.x + areaBounds.width, -chart.depth, y - 0.1);
            var bottomRightBackVector = chart.vector.vector3D(areaBounds.x, -0.1, offset);
            var topSideWallPlans = chart.polygon.createBox(topLeftFrontVector, bottomRightBackVector, chart, 0, chart.wallColor || chart.themeStyle.leftWallColor, chart.wallColor || chart.themeStyle.leftWallColor, 0, chart.theme.indexOf('Fluent2') > -1 ? 0.3 : chart.theme.indexOf('Bootstrap5') > -1 ? 0.1 : 0.5, false, 'top-wall-brush', chart.chart3D);
            for (var i = 0; i < topSideWallPlans.length; i++) {
                chart.polygon.transform(chart.matrixObj.tilt(Math.PI / 2), topSideWallPlans[i]);
            }
        };
        WallRenderer.prototype.updateRightWall = function (chart) {
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var x = areaBounds.x + areaBounds.width;
            var rightRect = { left: -chart.depth, top: areaBounds.y, bottom: areaBounds.height + areaBounds.y, right: 0 };
            var topLeftFrontVector = chart.vector.vector3D(rightRect.left, rightRect.top, x + 1.5);
            var bottomRightBackVector = chart.vector.vector3D(rightRect.right, rightRect.bottom, x + chart.wallSize);
            var rightSideWallPlans = chart.polygon.createBox(topLeftFrontVector, bottomRightBackVector, chart, 0, chart.wallColor || chart.themeStyle.leftWallColor, chart.wallColor || chart.themeStyle.leftWallColor, 0, chart.theme.indexOf('Fluent2') > -1 ? 0.3 : chart.theme.indexOf('Bootstrap5') > -1 ? 0.1 : 0.5, false, 'right-wall-brush', chart.chart3D);
            for (var i = 0; i < rightSideWallPlans.length; i++) {
                chart.polygon.transform(chart.matrixObj.turn(-Math.PI / 2), rightSideWallPlans[i]);
            }
        };
        WallRenderer.prototype.updateBackWall = function (chart) {
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var topLeftFrontVector = chart.vector.vector3D(areaBounds.x, areaBounds.y, chart.depth === 0 ? 1.5 : chart.depth + chart.wallSize);
            var bottomRightBackVector = chart.vector.vector3D((areaBounds.x + areaBounds.width), areaBounds.y + areaBounds.height, chart.depth === 0 ? 1.5 : chart.depth);
            chart.polygon.createBox(topLeftFrontVector, bottomRightBackVector, chart, 0, chart.wallColor || chart.themeStyle.backWallColor, chart.wallColor || chart.themeStyle.backWallColor, 0, chart.theme.indexOf('Fluent2') > -1 ? 0.3 : chart.theme.indexOf('Bootstrap5') > -1 ? 0.1 : 0.25, false, 'back-wall-brush', chart.chart3D);
        };
        WallRenderer.prototype.updateLeftWall = function (chart) {
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var leftRect = { left: -chart.depth, top: areaBounds.y, bottom: areaBounds.height + areaBounds.y, right: 0 };
            var offset = areaBounds.x;
            var topLeftFrontVector = chart.vector.vector3D(leftRect.left, leftRect.top, offset - 0.1);
            var bottomRightBackVector = chart.vector.vector3D(leftRect.right, leftRect.bottom, offset - chart.wallSize);
            var leftSideWallPlans = chart.polygon.createBox(topLeftFrontVector, bottomRightBackVector, chart, 0, chart.wallColor || chart.themeStyle.leftWallColor, chart.wallColor || chart.themeStyle.leftWallColor, 0, chart.theme.indexOf('Fluent2') > -1 ? 0.3 : chart.theme.indexOf('Bootstrap5') > -1 ? 0.1 : 0.5, false, 'left-wall-brush', chart.chart3D);
            for (var i = 0; i < leftSideWallPlans.length; i++) {
                chart.polygon.transform(chart.matrixObj.turn(-Math.PI / 2), leftSideWallPlans[i]);
            }
        };
        WallRenderer.prototype.updateBottomWall = function (chart) {
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var y = areaBounds.y + areaBounds.height;
            var topLeftFrontVector = chart.vector.vector3D((areaBounds.x + areaBounds.width), -chart.depth, chart.wallSize + y);
            var bottomRightBackVector = chart.vector.vector3D(areaBounds.x, -0.1, y + 1);
            var bottomSideWallPlans = chart.polygon.createBox(bottomRightBackVector, topLeftFrontVector, chart, 0, chart.wallColor || chart.themeStyle.leftWallColor, chart.wallColor || chart.themeStyle.leftWallColor, 0, chart.theme.indexOf('Fluent2') > -1 ? 0.3 : chart.theme.indexOf('Bootstrap5') > -1 ? 0.1 : 0.5, false, 'bottom-wall-brush', chart.chart3D);
            for (var i = 0; i < bottomSideWallPlans.length; i++) {
                chart.polygon.transform(chart.matrixObj.tilt(Math.PI / 2), bottomSideWallPlans[i]);
            }
        };
        return WallRenderer;
    }());
    exports.WallRenderer = WallRenderer;
    var AxisRenderer = (function () {
        function AxisRenderer() {
        }
        AxisRenderer.prototype.drawAxes = function (index, axis, chart) {
            if (axis.majorGridLines.width) {
                this.drawGridLines3D(axis, chart, index);
            }
            if (axis.visible && axis.internalVisibility && axis.majorTickLines.width) {
                this.renderTicks3D(axis, axis.majorTickLines.height, axis.majorTickLines.width, chart, index);
            }
            if (axis.visible && axis.internalVisibility) {
                this.drawAxisLabel(axis, chart, index);
                this.drawAxisTitle(axis, chart, index);
            }
        };
        AxisRenderer.prototype.drawAxisTitle = function (axis, chart, index) {
            if (axis.title) {
                var font = {
                    size: axis.titleStyle.size || chart.themeStyle.axisTitleFont.size,
                    fontWeight: axis.titleStyle.fontWeight || chart.themeStyle.axisTitleFont.fontWeight,
                    fontStyle: axis.titleStyle.fontStyle || chart.themeStyle.axisTitleFont.fontStyle,
                    fontFamily: axis.titleStyle.fontFamily || chart.themeStyle.axisTitleFont.fontFamily,
                    color: axis.titleStyle.color,
                    opacity: axis.titleStyle.opacity
                };
                var opposedPosition = axis.opposedPosition || axis.isAxisOpposedPosition;
                var size = { width: chart.availableSize.width, height: chart.availableSize.height };
                var transform = chart.transform3D.transform3D(size);
                transform.viewingArea = size;
                transform.rotation = 0;
                transform.tilt = 0;
                transform.depth = 100;
                transform.perspectiveAngle = 90;
                chart.transform3D.transform(transform);
                var orientation_1 = axis.orientation.toLowerCase();
                var elementSpacing = 10;
                if (orientation_1 === 'horizontal') {
                    var padding = 0;
                    var titlesize = (ej2_svg_base_1.measureText(axis.title, axis.titleStyle, chart.themeStyle.axisTitleFont).height / 2);
                    if (axis.titleRotation) {
                        padding = axis.titlePadding + (elementSpacing) + axis.labelPadding + (axis.titleSize.height / 2);
                    }
                    else {
                        padding = axis.titlePadding + titlesize + axis.labelPadding + elementSpacing;
                    }
                    var xtitleLocation = axis.maxLabelSize.height + padding;
                    var data = {
                        text: axis.title,
                        location: {
                            x: (axis.rect.width) / 2,
                            y: (xtitleLocation + axis.majorTickLines.height + chart.wallSize)
                        }
                    };
                    var x1 = data.location.x + axis.rect.x;
                    var y1 = (opposedPosition) ? (axis.rect.y - data.location.y) : (data.location.y + axis.rect.y);
                    var element = { width: 0, height: 0, angle: axis.titleRotation ? axis.titleRotation : 0, label: data, textAnchor: 'middle', tag: 'text', font: font, id: chart.element.id + '-svg-axis-title-' + index, child: chart.chart3D };
                    element.font.color = element.font.color ? element.font.color : chart.themeStyle.axisTitle;
                    element.font.fontFamily = element.font.fontFamily ? element.font.fontFamily : chart.themeStyle.axisTitleFont.fontFamily;
                    chart.graphics.addVisual(chart.polygon.createTextElement(chart.vector.vector3D(x1, y1, 0), element, 10, 10), chart);
                }
                else {
                    var titleSize = ej2_svg_base_1.measureText(axis.title, axis.titleStyle, chart.themeStyle.axisTitleFont);
                    var padding = 0;
                    if (axis.titleRotation) {
                        padding = axis.labelPadding + axis.titlePadding + axis.titleSize.width / 2;
                    }
                    else {
                        padding = axis.titlePadding + axis.labelPadding;
                    }
                    var x1 = (opposedPosition) ? axis.rect.x + ((elementSpacing) + axis.maxLabelSize.width +
                        axis.majorTickLines.height + chart.wallSize + padding) : axis.rect.x - ((elementSpacing) +
                        axis.maxLabelSize.width + axis.majorTickLines.height + chart.wallSize + padding);
                    var angle = (axis.titleRotation == null ? (opposedPosition ? 90 : -90) : axis.titleRotation) % 360;
                    var data = {
                        text: axis.title,
                        location: {
                            x: titleSize.width / 2,
                            y: 0
                        }
                    };
                    var y1 = data.location.y + (axis.rect.y + axis.rect.height) + (((axis.rect.height) / 2) * -1);
                    var element = { width: titleSize.width, height: titleSize.height, angle: angle, label: data, textAnchor: 'middle', tag: 'text', font: font, id: chart.element.id + '-svg-axis-title-' + index, child: chart.chart3D };
                    element.font.color = element.font.color ? element.font.color : chart.themeStyle.axisTitle;
                    element.font.fontFamily = element.font.fontFamily ? element.font.fontFamily : chart.themeStyle.axisTitleFont.fontFamily;
                    chart.graphics.addVisual(chart.polygon.createTextElement(chart.vector.vector3D(x1, y1, 0), element, 10, 10), chart);
                }
            }
        };
        AxisRenderer.prototype.textTrim = function (maxWidth, text, labelStyle, font) {
            var textLength = text.length;
            var trimmedSize;
            var label;
            var textSize = ej2_svg_base_1.measureText(text, labelStyle, font);
            if (textSize.width > maxWidth) {
                for (var k = textLength - 1; k >= 0; --k) {
                    label = text.substring(0, k) + '...';
                    trimmedSize = ej2_svg_base_1.measureText(label, labelStyle, font);
                    if (trimmedSize.width <= maxWidth) {
                        return label;
                    }
                }
                return '';
            }
            else {
                return text;
            }
        };
        AxisRenderer.prototype.multipleRows = function (length, currentX, currentLabel, axis, font) {
            var label;
            var pointX;
            var labelSize;
            var store = [];
            var isMultiRows;
            for (var i = length - 1; i >= 0; i--) {
                label = axis.visibleLabels[i];
                labelSize = ej2_svg_base_1.measureText(label.text, axis.labelStyle, font);
                pointX = chart3dRender_1.valueToCoefficients(i, axis) * axis.rect.width + axis.rect.x;
                isMultiRows = currentX < (pointX + labelSize.width / 2);
                if (isMultiRows) {
                    label.index = label.index ? label.index : 0;
                    store.push(label.index);
                    currentLabel.index = (currentLabel.index > label.index) ? currentLabel.index : label.index + 1;
                }
                else {
                    currentLabel.index = store.indexOf(label.index) > -1 ? currentLabel.index : label.index;
                }
            }
        };
        AxisRenderer.prototype.drawAxisLabel = function (axis, chart, index) {
            var labels = [];
            var angleValue;
            var labelsCount = axis.visibleLabels.length;
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var opposedPosition = axis.opposedPosition || axis.isAxisOpposedPosition;
            var elementSpacing = axis.angle ? 5 : 10;
            var y = areaBounds.y + (!opposedPosition && areaBounds.height);
            var x = areaBounds.x + (opposedPosition && areaBounds.width);
            for (var i = 0; i < labelsCount; i++) {
                Eif (!ej2_base_1.isNullOrUndefined(axis.visibleLabels[i].text)) {
                    var x1 = 0;
                    var y1 = 0;
                    var pointX = void 0;
                    axis.visibleLabels[i].originalText = axis.visibleLabels[i].text;
                    var textAnchor = void 0;
                    var textSize = ej2_svg_base_1.measureText(axis.visibleLabels[i].text, axis.labelStyle, chart.themeStyle.axisLabelFont);
                    var value = (axis.visibleLabels[i].value - axis.visibleRange.min) / axis.visibleRange.delta;
                    value = axis.isInversed || axis.isAxisInverse ? 1 - value : value;
                    value = isNaN(value) ? 0 : value;
                    if (axis.orientation.toLowerCase() === 'horizontal') {
                        x1 = Math.round(axis.rect.width * value) + areaBounds.x + axis.plotOffset;
                        y1 = opposedPosition ? (y - chart.wallSize - axis.majorTickLines.height - axis.labelPadding - elementSpacing / 2) :
                            y + chart.wallSize + axis.majorTickLines.height + elementSpacing + axis.labelPadding;
                        textAnchor = 'middle';
                    }
                    else {
                        y1 = Math.round(axis.plotOffset + axis.rect.y + (textSize.height / 4) + (axis.rect.height * (1 - value)));
                        var padding = 0;
                        Iif (axis.labelRotation === 90 || axis.labelRotation === -90 ||
                            axis.labelRotation === 270 || axis.labelRotation === -270) {
                            padding = elementSpacing * 2;
                        }
                        else {
                            padding = elementSpacing;
                        }
                        x1 = opposedPosition ? (axis.rect.x + axis.majorTickLines.height + padding + axis.labelPadding) :
                            (x - chart.wallSize - axis.majorTickLines.height - padding + axis.labelPadding);
                        textAnchor = opposedPosition ? (axis.isRTLEnabled ? 'end' : 'start') : (axis.isRTLEnabled ? 'start' : 'end');
                    }
                    labels.push({ x: x1, y: y1, size: textSize });
                    var maxWidth = axis.rect.width / axis.visibleLabels.length - 5;
                    var label = labels[i];
                    if (((label.x > axis.rect.x && i === 0) ||
                        (label.x + label.size.width / 2 > axis.rect.x + axis.rect.width && i === axis.visibleLabels.length - 1)) &&
                        axis.labelIntersectAction !== 'Trim' && axis.labelIntersectAction.indexOf('wrap') < 0) {
                        Iif (axis.edgeLabelPlacement === 'Hide') {
                            continue;
                        }
                        else Iif (axis.edgeLabelPlacement === 'Shift') {
                            if (i === 0) {
                                label.x = x1 = axis.rect.x + label.size.width / 2;
                            }
                            else if (i === axis.visibleLabels.length - 1) {
                                label.x = x1 = axis.rect.x + axis.rect.width - label.size.width / 2;
                            }
                        }
                    }
                    if (axis.orientation.toLowerCase() === 'horizontal') {
                        if (axis.labelRotation) {
                            angleValue = axis.labelRotation;
                            var rotatedSize = helper_1.rotateTextSize(axis.labelStyle, axis.visibleLabels[i].text, angleValue, chart, chart.themeStyle.axisLabelFont);
                            y1 += rotatedSize.height / 2;
                        }
                        else {
                            if (axis.labelIntersectAction === 'Trim') {
                                axis.visibleLabels[i].text = this.textTrim(maxWidth, axis.visibleLabels[i].text, axis.labelStyle, chart.themeStyle.axisLabelFont);
                            }
                            else if (axis.angle && (axis.labelIntersectAction === 'Rotate45' || axis.labelIntersectAction === 'Rotate90')) {
                                var rotatedSize = helper_1.rotateTextSize(axis.labelStyle, axis.visibleLabels[i].text, axis.angle, chart, chart.themeStyle.axisLabelFont);
                                y1 += rotatedSize.height / 2;
                            }
                            else if (axis.labelIntersectAction === 'MultipleRows') {
                                pointX = label.x;
                                pointX -= textSize.width / 2;
                                this.multipleRows(i, pointX, axis.visibleLabels[i], axis, chart.themeStyle.axisLabelFont);
                                y1 = axis.visibleLabels[i].index ?
                                    y1 + axis.visibleLabels[i].index * (textSize.height + 5) : y1;
                            }
                            else if (axis.labelIntersectAction === 'Hide') {
                                var isAxisLabelHidden = false;
                                for (var j = 0; j < i; j++) {
                                    if (labels[j].x + (labels[j].size.width / 2) >=
                                        labels[i].x - (labels[i].size.width / 2)) {
                                        isAxisLabelHidden = true;
                                        break;
                                    }
                                }
                                if (isAxisLabelHidden) {
                                    continue;
                                }
                            }
                        }
                    }
                    var font = {
                        size: axis.visibleLabels[i].labelStyle.size,
                        fontWeight: axis.visibleLabels[i].labelStyle.fontWeight,
                        fontStyle: axis.visibleLabels[i].labelStyle.fontStyle,
                        fontFamily: axis.visibleLabels[i].labelStyle.fontFamily,
                        color: axis.visibleLabels[i].labelStyle.color,
                        opacity: axis.visibleLabels[i].labelStyle.opacity
                    };
                    var element = {
                        width: textSize.width, height: textSize.height, label: axis.visibleLabels[i], textAnchor: textAnchor,
                        tag: 'text', font: font, id: chart.element.id + '-' + index + '-axis-label-' + i, child: chart.chart3D, angle: axis.angle
                    };
                    element.font.color = element.font.color ? element.font.color : chart.themeStyle.axisLabel;
                    element.font.fontFamily = element.font.fontFamily ? element.font.fontFamily : chart.themeStyle.axisLabelFont.fontFamily;
                    chart.graphics.addVisual(chart.polygon.createTextElement(chart.vector.vector3D(x1, y1, 0), element, 10, 10), chart);
                }
            }
        };
        AxisRenderer.prototype.renderTicks3D = function (axis, size, width, chart, index) {
            var labelsCount = axis.visibleLabels.length;
            var minorTicks;
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var ticksbwtLabel = (axis.valueType === 'Category' && axis.labelPlacement === 'BetweenTicks') ? 0.5 : 0;
            labelsCount += (axis.valueType === 'Category' && labelsCount > 0 && axis.labelPlacement === 'BetweenTicks') ? 1 : 0;
            var labelValue;
            for (var i = 0; i < labelsCount; i++) {
                Eif (axis.valueType !== 'DateTimeCategory') {
                    labelValue = axis.visibleLabels[i] ? axis.visibleLabels[i].value - ticksbwtLabel :
                        (axis.visibleLabels[i - 1].value + axis.visibleRange.interval) - ticksbwtLabel;
                }
                else {
                    labelValue = axis.visibleLabels[i].value ? axis.visibleLabels[i].value - ticksbwtLabel
                        : axis.visibleRange.max;
                }
                var x1 = 0;
                var x2 = 0;
                var y1 = 0;
                var y2 = 0;
                var value = (labelValue - axis.visibleRange.min) / axis.visibleRange.delta;
                value = axis.isInversed || axis.isAxisInverse ? 1 - value : value;
                value = isNaN(value) ? 0 : value;
                if (axis.orientation.toLowerCase() === 'horizontal') {
                    x2 = x1 = (Math.round(axis.rect.width * value)) + areaBounds.x + axis.plotOffset;
                }
                else {
                    y1 = y2 = Math.round(axis.plotOffset + (axis.rect.height * (1 - value))) + axis.rect.y;
                }
                var position = this.calculatePosition3D(axis, size, width, x1, y1, x2, y2, chart);
                var line = { width: axis.majorTickLines.width, opacity: 1, stroke: axis.majorTickLines.color || chart.themeStyle.majorTickLine, child: chart.chart3D, tag: 'line', id: '' };
                line.id = chart.element.id + '-' + index + '-major-tick-lines-' + i;
                chart.graphics.addVisual(chart.polygon.createLine(line, position.x1, position.y1, position.x2, position.y2, 0), chart);
                if (axis.minorGridLines.width && axis.minorTicksPerInterval > 0 && i < labelsCount - 1) {
                    minorTicks = axis.visibleRange.interval / (axis.minorTicksPerInterval + 1);
                    for (var k = 0; k < axis.minorTicksPerInterval; k++) {
                        value = chart3dRender_1.valueToCoefficients(axis.visibleLabels[i].value + (minorTicks * (k + 1)), axis);
                        value = isNaN(value) ? 0 : value;
                        if (axis.orientation.toLowerCase() === 'horizontal') {
                            x1 = x2 = Math.round(axis.plotOffset + (areaBounds.width * value) + areaBounds.x);
                        }
                        else {
                            y1 = y2 = Math.round(axis.plotOffset + ((areaBounds.height) * (1 - value))) + axis.rect.y;
                        }
                        var position_1 = this.calculatePosition3D(axis, size, width, x1, y1, x2, y2, chart);
                        var line_1 = { width: axis.minorTickLines.width, opacity: 0.6, stroke: axis.minorTickLines.color || chart.themeStyle.minorTickLine, child: chart.chart3D, tag: 'line', id: '' };
                        line_1.id = chart.element.id + '-' + index + '-minor-tick-lines-' + i + '-' + k;
                        chart.graphics.addVisual(chart.polygon.createLine(line_1, position_1.x1, position_1.y1, position_1.x2, position_1.y2, 0), chart);
                    }
                }
            }
        };
        AxisRenderer.prototype.calculatePosition3D = function (axis, tickSize, width, x1, y1, x2, y2, chart) {
            var isOpposed = axis.opposedPosition || axis.isAxisOpposedPosition;
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            var y = areaBounds.y + (!isOpposed && areaBounds.height);
            var x = areaBounds.x + (isOpposed && areaBounds.width);
            if (axis.orientation.toLowerCase() === 'horizontal') {
                y1 = 0;
                y2 = isOpposed ? tickSize : y1 + tickSize;
                var screenPositionTop = isOpposed ? y - chart.wallSize - tickSize : y + chart.wallSize - (tickSize / 2);
                y1 += screenPositionTop;
                y2 += screenPositionTop;
                x1 = x2 = x1;
            }
            else {
                x1 = 0;
                x2 = isOpposed ? x1 + tickSize : tickSize;
                var screenPositionLeft = isOpposed ? x + chart.wallSize : (x - chart.wallSize - tickSize);
                x1 += screenPositionLeft;
                x2 += screenPositionLeft;
                y1 = y2 = y1;
            }
            return { x1: x1, y1: y1, x2: x2, y2: y2 };
        };
        AxisRenderer.prototype.drawGridLines3D = function (axis, chart, index) {
            Iif (axis == null) {
                return;
            }
            var labelsCount = axis.visibleLabels.length;
            var minorTicks;
            var opposedPosition = axis.opposedPosition || axis.isAxisOpposedPosition;
            var orientation = axis.orientation;
            var x1;
            var x2;
            var y1;
            var y2;
            var labelValue;
            var ticksbwtLabel = (axis.valueType === 'Category' && axis.labelPlacement === 'BetweenTicks') ? 0.5 : 0;
            labelsCount += (axis.valueType === 'Category' && labelsCount > 0 && axis.labelPlacement === 'BetweenTicks') ? 1 : 0;
            var areaBounds = chart.chartAxisLayoutPanel.seriesClipRect;
            if (orientation.toLowerCase() === 'horizontal') {
                var i = void 0;
                for (i = 0; i < labelsCount; i++) {
                    if (axis.valueType !== 'DateTimeCategory') {
                        labelValue = axis.visibleLabels[i] ? axis.visibleLabels[i].value - ticksbwtLabel :
                            (axis.visibleLabels[i - 1].value + axis.visibleRange.interval) - ticksbwtLabel;
                    }
                    else {
                        labelValue = axis.visibleLabels[i].value ? axis.visibleLabels[i].value - ticksbwtLabel
                            : axis.visibleRange.max;
                    }
                    var value = chart3dRender_1.valueToCoefficients(labelValue, axis);
                    value = isNaN(value) ? 0 : value;
                    x2 = x1 = (Math.round(axis.rect.width * value)) + areaBounds.x + axis.plotOffset;
                    y1 = areaBounds.y;
                    y2 = areaBounds.y + areaBounds.height;
                    var depth = chart.depth > 2 ? chart.depth - 2 : 1;
                    var bottom = areaBounds.y + (!opposedPosition && areaBounds.height);
                    var line = { opacity: 1, width: axis.majorGridLines.width, stroke: axis.majorGridLines.color || chart.themeStyle.majorGridLine, child: chart.chart3D, tag: 'line', id: '' };
                    line.id = chart.element.id + '-' + index + '-grid-lines-' + i;
                    chart.graphics.addVisual(chart.polygon.createLine(line, x1, y1, x2, y2, depth), chart);
                    var parallelLine = { opacity: line.opacity, width: line.width, stroke: line.stroke, child: line.child, tag: line.tag, id: '' };
                    parallelLine.id = line.id + '-parallel';
                    parallelLine.id = chart.element.id + '-' + index + '-parallel-grid-lines-' + i;
                    var line3D = chart.polygon.createLine(parallelLine, x2, 0, x2, -depth, bottom);
                    chart.polygon.transform(chart.matrixObj.tilt(Math.PI / 2), line3D);
                    chart.graphics.addVisual(line3D, chart);
                    if (axis.minorGridLines.width && axis.minorTicksPerInterval > 0 && i < labelsCount - 1) {
                        minorTicks = axis.visibleRange.interval / (axis.minorTicksPerInterval + 1);
                        for (var k = 0; k < axis.minorTicksPerInterval; k++) {
                            value = chart3dRender_1.valueToCoefficients(axis.visibleLabels[i].value + (minorTicks * (k + 1)), axis);
                            value = isNaN(value) ? 0 : value;
                            x2 = x1 = (Math.round(areaBounds.width * value) + areaBounds.x);
                            y1 = areaBounds.y;
                            y2 = areaBounds.y + areaBounds.height;
                            var line_2 = { opacity: 0.6, width: axis.minorGridLines.width, stroke: axis.minorGridLines.color || chart.themeStyle.minorGridLine, child: chart.chart3D, tag: 'line', id: '' };
                            line_2.id = chart.element.id + '-' + index + '-minor-grid-lines-' + i + '-' + k;
                            chart.graphics.addVisual(chart.polygon.createLine(line_2, x1, y1, x2, y2, depth), chart);
                            var parallelLine_1 = { opacity: line_2.opacity, width: line_2.width, stroke: line_2.stroke, child: line_2.child, tag: line_2.tag, id: '' };
                            parallelLine_1.id = chart.element.id + '-' + index + '-parallel-minor-grid-lines-' + i + '-' + k;
                            var line3D_1 = chart.polygon.createLine(parallelLine_1, x2, 0, x2, -depth, bottom);
                            chart.polygon.transform(chart.matrixObj.tilt(Math.PI / 2), line3D_1);
                            chart.graphics.addVisual(line3D_1, chart);
                        }
                    }
                }
            }
            else {
                for (var i = 0; i < labelsCount; i++) {
                    labelValue = axis.visibleLabels[i] ? axis.visibleLabels[i].value - ticksbwtLabel :
                        (axis.visibleLabels[i - 1].value + axis.visibleRange.interval) - ticksbwtLabel;
                    var value = (labelValue - axis.visibleRange.min) / axis.visibleRange.delta;
                    x1 = areaBounds.x;
                    y1 = Math.round((axis.rect.height) * (1 - value)) + 0.5;
                    y1 += axis.rect.y;
                    x2 = x1 + areaBounds.width;
                    y2 = y1;
                    var depth = chart.depth > 2 ? chart.depth - 2 : 1;
                    var line = { opacity: 1, width: axis.majorGridLines.width, stroke: axis.majorGridLines.color || chart.themeStyle.majorGridLine, axisName: axis.name, child: chart.chart3D, tag: 'line', id: '' };
                    line.id = chart.element.id + '-' + index + '-grid-lines-' + i;
                    chart.graphics.addVisual(chart.polygon.createLine(line, x1, y1, x2, y2, depth), chart);
                    var depthD = areaBounds.x + (opposedPosition && areaBounds.width + 1);
                    var sideLine = { opacity: line.opacity, width: line.width, stroke: line.stroke, child: line.child, tag: line.tag, id: '' };
                    sideLine.id = chart.element.id + '-' + index + '-parallel-grid-lines-' + i;
                    var line3D = chart.polygon.createLine(sideLine, -depth, y2, 0, y2, depthD);
                    chart.polygon.transform(chart.matrixObj.turn(-Math.PI / 2), line3D);
                    chart.graphics.addVisual(line3D, chart);
                    if (axis.minorGridLines.width && axis.minorTicksPerInterval > 0 && i < labelsCount - 1) {
                        minorTicks = axis.visibleRange.interval / (axis.minorTicksPerInterval + 1);
                        for (var k = 0; k < axis.minorTicksPerInterval; k++) {
                            var value_1 = chart3dRender_1.valueToCoefficients(axis.visibleLabels[i].value + (minorTicks * (k + 1)), axis);
                            x1 = areaBounds.x;
                            y1 = Math.round((axis.rect.height) * (1 - value_1)) + 0.5;
                            y1 += axis.rect.y;
                            x2 = x1 + areaBounds.width;
                            y2 = y1;
                            var line_3 = { opacity: 0.6, width: axis.minorGridLines.width, stroke: axis.minorGridLines.color || chart.themeStyle.minorGridLine, axisName: axis.name, child: chart.chart3D, tag: 'line', id: '' };
                            line_3.id = chart.element.id + '-' + index + '-minor-grid-lines-' + i + '-' + k;
                            chart.graphics.addVisual(chart.polygon.createLine(line_3, x1, y1, x2, y2, depth), chart);
                            var sideLine_1 = { opacity: line_3.opacity, width: line_3.width, stroke: line_3.stroke, child: line_3.child, tag: line_3.tag, id: '' };
                            sideLine_1.id = chart.element.id + '-' + index + '-parallel-minor-grid-lines-' + i + k;
                            var line3D_2 = chart.polygon.createLine(sideLine_1, -depth, y2, 0, y2, depthD);
                            chart.polygon.transform(chart.matrixObj.turn(-Math.PI / 2), line3D_2);
                            chart.graphics.addVisual(line3D_2, chart);
                        }
                    }
                }
            }
        };
        return AxisRenderer;
    }());
    exports.AxisRenderer = AxisRenderer;
});