all files / linear-gauge/axes/ axis-panel.js

98.19% Statements 326/332
91.62% Branches 448/489
100% Functions 21/21
98.19% Lines 326/332
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   498×   546× 546× 546× 546× 546× 546× 546× 546× 546× 546× 546× 611× 611× 611× 611× 611× 611× 611× 606×   611× 611×   611× 611× 611× 241× 241× 241× 241×       370× 370× 370× 370×   611×     611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 241×   241× 241×     370×   370× 370×   611× 611× 611× 18× 18× 16× 16× 16×     18×     611× 595× 232×     363×       16× 16×         611× 611×     611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611×   611× 611× 611× 241×   241×       241× 241×   241×   241×       241× 241×       370×   370×       370× 370×   370×   370×       370× 370×       611× 611× 611× 611×   611×     611× 611× 611×     605× 605× 605× 238×   238× 238×   238×             238×       238×     367×   367× 367×   367×             367×       367×   605×     606× 606× 606× 606× 606× 703× 703× 44×       659×   703×     703× 703×       1391× 1391× 1391× 1391× 1391× 1391× 1391× 1391× 1391× 1391× 1391× 327× 213×   213×       114×           327×     1064× 327×   327×       737×           1064×   1391× 1391×     117× 117× 117× 117× 117× 117× 117× 117× 117× 117× 117× 117× 117× 43× 38×   38×             43× 43× 43× 43× 43×     74× 68×   68×             74× 74× 74× 74× 74×   117× 117×           611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 611× 768× 768× 21×   768×         768×   768× 768× 768× 751× 751× 751× 751× 751× 751×   751×   751× 286×     286× 286× 286× 286×     286×     286×         465× 465×   465× 465× 465×     465×     465×             661× 661× 661× 661× 68× 68×     593×   661×   611× 611× 605× 605× 605× 605× 605× 605× 605× 605× 6402× 6402×       6402×           6402× 6381× 6381×     6402× 6402×   605× 605× 6402×   605× 605× 605×                 605×     605× 605× 605× 6383× 6383× 6383× 1691×   6383× 591×       546× 56× 70×             468×        
define(["require", "exports", "@syncfusion/ej2-base", "../model/constant", "../utils/helper", "../utils/helper"], function (require, exports, ej2_base_1, constant_1, helper_1, helper_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AxisLayoutPanel = (function () {
        function AxisLayoutPanel(gauge) {
            this.gauge = gauge;
        }
        AxisLayoutPanel.prototype.calculateAxesBounds = function () {
            var axis;
            var bounds;
            this.gauge.nearSizes = [];
            this.gauge.farSizes = [];
            var x;
            var y;
            var width;
            var height;
            var axisPadding = 8;
            this.checkThermometer();
            for (var i = 0; i < this.gauge.axes.length; i++) {
                axis = this.gauge.axes[i];
                axis.checkAlign = new helper_1.Align(i, ((!axis.opposedPosition) ? 'Near' : 'Far'));
                (!axis.opposedPosition) ? this.gauge.nearSizes.push(1) : this.gauge.farSizes.push(1);
                this.calculateLineBounds(axis, i);
                this.calculateTickBounds(axis);
                this.calculateLabelBounds(axis);
                if (axis.pointers.length > 0) {
                    this.calculatePointerBounds(axis);
                }
                Eif (axis.ranges.length > 0) {
                    this.calculateRangesBounds(axis);
                }
                bounds = axis.labelBounds;
                var offset = this.gauge.axes[i].labelStyle.offset;
                if (this.gauge.orientation === 'Vertical') {
                    x = (!axis.opposedPosition) ? bounds.x - offset - axisPadding : axis.lineBounds.x;
                    y = axis.lineBounds.y;
                    height = axis.lineBounds.height;
                    width = Math.abs((!axis.opposedPosition) ? (axis.lineBounds.x - x) :
                        ((bounds.x + bounds.width + axisPadding) - x - offset));
                }
                else {
                    y = (!axis.opposedPosition) ? bounds.y - bounds.height - offset - axisPadding : axis.lineBounds.y;
                    x = axis.lineBounds.x;
                    width = axis.lineBounds.width;
                    height = Math.abs((!axis.opposedPosition) ? Math.abs(axis.lineBounds.y - y) : (bounds.y + axisPadding) - y - offset);
                }
                axis.bounds = new helper_1.Rect(x, y, width, height);
            }
        };
        AxisLayoutPanel.prototype.calculateLineBounds = function (axis, axisIndex) {
            var x;
            var y;
            var width;
            var height;
            var prevAxis;
            var lineHeight = axis.line.height;
            var orientation = this.gauge.orientation;
            var containerRect = this.gauge.containerBounds;
            lineHeight = (axis.line.width > 0) ? lineHeight : null;
            if (orientation === 'Vertical') {
                y = (ej2_base_1.isNullOrUndefined(lineHeight)) ? containerRect.y :
                    containerRect.y + ((containerRect.height / 2) - (lineHeight / 2));
                width = axis.line.width;
                height = (ej2_base_1.isNullOrUndefined(lineHeight)) ? containerRect.height : lineHeight;
            }
            else {
                x = (ej2_base_1.isNullOrUndefined(lineHeight)) ? containerRect.x :
                    containerRect.x + ((containerRect.width / 2) - (lineHeight / 2));
                height = axis.line.width;
                width = (ej2_base_1.isNullOrUndefined(lineHeight)) ? containerRect.width : lineHeight;
            }
            var index = this.checkPreviousAxes(axis, axisIndex);
            var count = 0;
            if (!ej2_base_1.isNullOrUndefined(index)) {
                for (var i = index; i >= 0; i--) {
                    if (this.gauge.axes[i].minimum !== this.gauge.axes[i].maximum) {
                        index = i;
                        count++;
                        break;
                    }
                }
                if (count === 0) {
                    index = null;
                }
            }
            if (ej2_base_1.isNullOrUndefined(index)) {
                if (orientation === 'Vertical') {
                    x = (!axis.opposedPosition ? containerRect.x : containerRect.x + containerRect.width) + axis.line.offset;
                }
                else {
                    y = (!axis.opposedPosition ? containerRect.y : containerRect.y + containerRect.height) + axis.line.offset;
                }
            }
            else {
                prevAxis = this.gauge.axes[index];
                if (orientation === 'Vertical') {
                    x = ((!axis.opposedPosition) ? prevAxis.bounds.x : (prevAxis.bounds.x + prevAxis.bounds.width)) + axis.line.offset;
                }
                else {
                    y = ((!axis.opposedPosition) ? prevAxis.bounds.y : (prevAxis.bounds.y + prevAxis.bounds.height)) + axis.line.offset;
                }
            }
            axis.lineBounds = new helper_1.Rect(x, y, width, height);
            if (axis.minimum === axis.maximum) {
                axis.lineBounds = new helper_1.Rect(0, 0, 0, 0);
            }
        };
        AxisLayoutPanel.prototype.calculateTickBounds = function (axis) {
            var x;
            var y;
            var min = Math.min(axis.minimum, axis.maximum);
            var max = Math.max(axis.minimum, axis.maximum);
            min = (min === max) ? max - 1 : min;
            var bounds = axis.lineBounds;
            var major = axis.majorTicks;
            var minor = axis.minorTicks;
            axis.majorInterval = major.interval;
            axis.minorInterval = minor.interval;
            var size = (this.gauge.orientation === 'Vertical' ? bounds.height : bounds.width);
            var lineSize = (this.gauge.orientation === 'Vertical' ? bounds.width : bounds.height) / 2;
            axis.majorInterval = ej2_base_1.isNullOrUndefined(axis.majorInterval) ? helper_2.calculateNiceInterval(min, max, size, this.gauge.orientation)
                : major.interval;
            axis.visibleRange = new helper_2.VisibleRange(min, max, axis.majorInterval, (max - min));
            axis.minorInterval = (ej2_base_1.isNullOrUndefined(axis.minorInterval)) ? axis.majorInterval / 2 : axis.minorInterval;
            if (this.gauge.orientation === 'Vertical') {
                x = axis.majorTicks.position === 'Auto' ? ((!axis.opposedPosition ? (bounds.x - lineSize - major.height) : bounds.x + lineSize)
                    + major.offset) : x;
                x = axis.majorTicks.position !== 'Auto' ? (axis.majorTicks.position === 'Cross' ? bounds.x - major.height / 2 - major.offset :
                    ((axis.majorTicks.position === 'Inside' && !axis.opposedPosition) ||
                        (axis.majorTicks.position === 'Outside' && axis.opposedPosition)) ? (bounds.x - lineSize - major.height - major.offset)
                        : (bounds.x + lineSize + major.offset)) : x;
                axis.majorTickBounds = new helper_1.Rect(x, bounds.y, major.height, bounds.height);
                if (axis.minimum === axis.maximum) {
                    axis.majorTickBounds = new helper_1.Rect(0, 0, 0, 0);
                }
                x = axis.minorTicks.position === 'Auto' ? ((!axis.opposedPosition ? (bounds.x - lineSize - minor.height) : bounds.x + lineSize)
                    + minor.offset) : x;
                x = axis.minorTicks.position !== 'Auto' ? (axis.minorTicks.position === 'Cross' ? bounds.x - minor.height / 2 - minor.offset :
                    ((axis.minorTicks.position === 'Inside' && !axis.opposedPosition) ||
                        (axis.minorTicks.position === 'Outside' && axis.opposedPosition)) ? (bounds.x - lineSize - minor.height - minor.offset)
                        : (bounds.x + lineSize + minor.offset)) : x;
                axis.minorTickBounds = new helper_1.Rect(x, bounds.y, minor.height, bounds.height);
                if (axis.minimum === axis.maximum) {
                    axis.minorTickBounds = new helper_1.Rect(0, 0, 0, 0);
                }
            }
            else {
                y = axis.majorTicks.position === 'Auto' ? ((!axis.opposedPosition ? (bounds.y - lineSize - major.height) : bounds.y + lineSize)
                    + major.offset) : y;
                y = axis.majorTicks.position !== 'Auto' ? ((axis.majorTicks.position === 'Cross' ? bounds.y - major.height / 2 - major.offset :
                    ((axis.majorTicks.position === 'Inside' && !axis.opposedPosition) ||
                        (axis.majorTicks.position === 'Outside' && axis.opposedPosition)) ?
                        (bounds.y - lineSize - major.height) - major.offset : bounds.y + lineSize + major.offset)) : y;
                axis.majorTickBounds = new helper_1.Rect(bounds.x, y, bounds.width, major.height);
                if (axis.minimum === axis.maximum) {
                    axis.majorTickBounds = new helper_1.Rect(0, 0, 0, 0);
                }
                y = axis.minorTicks.position === 'Auto' ? ((!axis.opposedPosition ? (bounds.y - lineSize - minor.height) : bounds.y + lineSize)
                    + minor.offset) : y;
                y = axis.minorTicks.position !== 'Auto' ? ((axis.minorTicks.position === 'Cross' ? bounds.y - minor.height / 2 - major.offset :
                    ((axis.minorTicks.position === 'Inside' && !axis.opposedPosition) ||
                        (axis.minorTicks.position === 'Outside' && axis.opposedPosition)) ?
                        (bounds.y - lineSize - minor.height) - minor.offset : bounds.y + lineSize + minor.offset)) : y;
                axis.minorTickBounds = new helper_1.Rect(bounds.x, y, bounds.width, minor.height);
                if (axis.minimum === axis.maximum) {
                    axis.minorTickBounds = new helper_1.Rect(0, 0, 0, 0);
                }
            }
        };
        AxisLayoutPanel.prototype.calculateLabelBounds = function (axis) {
            var x;
            var y;
            var padding = 5;
            var applyPositionBounds = (axis.labelStyle.position !== 'Auto' && axis.majorTicks.position !== 'Auto' &&
                axis.minorTicks.position !== 'Auto');
            var bounds = applyPositionBounds ? (axis.labelStyle.position === axis.minorTicks.position &&
                axis.minorTicks.position !== axis.majorTicks.position ? axis.minorTickBounds : axis.majorTickBounds) :
                axis.majorTickBounds;
            var offset = axis.labelStyle.offset;
            this.calculateVisibleLabels(axis);
            if (axis.minimum === axis.maximum) {
                axis.labelBounds = new helper_1.Rect(0, 0, 0, 0);
            }
            else {
                var width = axis.maxLabelSize.width;
                var height = axis.maxLabelSize.height / 2;
                if (this.gauge.orientation === 'Vertical') {
                    x = axis.labelStyle.position === 'Auto' ? ((!axis.opposedPosition ? (bounds.x - width - padding) :
                        (bounds.x + bounds.width + padding)) + offset) : x;
                    var boundx = bounds.x;
                    var offsetForCross = axis.majorTicks.position === 'Cross' || axis.minorTicks.position === 'Cross' ?
                        (bounds.width > axis.lineBounds.width ? bounds.width / 2 : axis.lineBounds.width / 2) : axis.lineBounds.width / 2;
                    boundx = applyPositionBounds ? ((axis.labelStyle.position !== axis.minorTicks.position &&
                        axis.labelStyle.position !== axis.majorTicks.position) ?
                        (axis.minorTicks.position !== 'Cross' && axis.majorTicks.position !== 'Cross' ? (axis.labelStyle.position === 'Inside' ?
                            bounds.x - axis.lineBounds.width : axis.labelStyle.position === 'Outside' ?
                            bounds.x + axis.lineBounds.width : bounds.x) : (axis.labelStyle.position === 'Inside' ?
                            axis.lineBounds.x - offsetForCross : axis.labelStyle.position === 'Outside' ?
                            axis.lineBounds.x - bounds.width + offsetForCross : bounds.x)) : bounds.x) : bounds.x;
                    x = axis.labelStyle.position !== 'Auto' ? (axis.labelStyle.position === 'Cross' ? axis.lineBounds.x -
                        axis.maxLabelSize.width / 4 - offset : ((axis.labelStyle.position === 'Inside' && !axis.opposedPosition) ||
                        (axis.labelStyle.position === 'Outside' && axis.opposedPosition)) ?
                        ((boundx - width - padding) - offset) : ((boundx + bounds.width + padding) + offset)) : x;
                    y = axis.lineBounds.y;
                }
                else {
                    y = axis.labelStyle.position === 'Auto' ? ((!axis.opposedPosition ?
                        (bounds.y - padding) : ((bounds.y + bounds.height + padding) + height)) + offset) : y;
                    var boundy = bounds.y;
                    var offsetForCross = axis.majorTicks.position === 'Cross' || axis.minorTicks.position === 'Cross' ?
                        (bounds.height > axis.lineBounds.height ? bounds.height / 2 : axis.lineBounds.height / 2) : axis.lineBounds.height / 2;
                    boundy = applyPositionBounds ? ((axis.labelStyle.position !== axis.minorTicks.position &&
                        axis.labelStyle.position !== axis.majorTicks.position) ?
                        (axis.minorTicks.position !== 'Cross' && axis.majorTicks.position !== 'Cross' ?
                            (axis.labelStyle.position === 'Inside' ? bounds.y - axis.lineBounds.height : axis.labelStyle.position === 'Outside' ?
                                bounds.y + axis.lineBounds.height : bounds.y) : (axis.labelStyle.position === 'Inside' ?
                            axis.lineBounds.y - offsetForCross : axis.labelStyle.position === 'Outside' ?
                            axis.lineBounds.y - bounds.height + offsetForCross : bounds.y)) : bounds.y) : bounds.y;
                    y = axis.labelStyle.position !== 'Auto' ? (axis.labelStyle.position === 'Cross' ? axis.lineBounds.y +
                        axis.maxLabelSize.height / 4 - offset : ((axis.labelStyle.position === 'Inside' && !axis.opposedPosition) ||
                        (axis.labelStyle.position === 'Outside' && axis.opposedPosition)) ?
                        (boundy - padding) - offset : ((boundy + bounds.height + padding) + height) + offset) : y;
                    x = axis.lineBounds.x;
                }
                axis.labelBounds = new helper_1.Rect(x, y, width, height);
            }
        };
        AxisLayoutPanel.prototype.calculatePointerBounds = function (axis) {
            var pointer;
            var range = axis.visibleRange;
            var minimumValue = Math.min(range.min, range.max);
            var maximumValue = Math.max(range.min, range.max);
            for (var i = 0; i < axis.pointers.length; i++) {
                pointer = axis.pointers[i];
                if (!ej2_base_1.isNullOrUndefined(pointer.offset) && pointer.offset.length > 0) {
                    pointer.currentOffset = helper_1.stringToNumber(pointer.offset, (this.gauge.orientation === 'Horizontal' ?
                        this.gauge.availableSize.height / 2 : this.gauge.availableSize.width / 2));
                }
                else {
                    pointer.currentOffset = pointer.offset;
                }
                pointer.currentValue = pointer.value !== null ?
                    pointer.value < minimumValue ? minimumValue : pointer.value > maximumValue ? maximumValue : pointer.value
                    : minimumValue;
                Eif (pointer.width > 0 && helper_2.withInRange(pointer.currentValue, null, null, range.max, range.min, 'pointer')) {
                    this['calculate' + pointer.type + 'Bounds'](axis, pointer);
                }
            }
        };
        AxisLayoutPanel.prototype.calculateMarkerBounds = function (axis, pointer) {
            var x;
            var y;
            var line = axis.lineBounds;
            var offset = pointer.currentOffset;
            var range = axis.visibleRange;
            var placement = pointer.placement;
            var tick = axis.majorTickBounds;
            var label = axis.labelBounds;
            var border = pointer.border.width;
            var textSize = helper_1.measureText(pointer.text, pointer.textStyle);
            if (this.gauge.orientation === 'Vertical') {
                if (pointer.position === 'Auto') {
                    x = (!axis.opposedPosition) ? (placement === 'Near') ? label.x : (placement === 'Center') ? tick.x : line.x :
                        placement === 'Far' ? label.x + label.width : (placement === 'Center' ? tick.x + tick.width : line.x);
                    x = !axis.opposedPosition ? ((pointer.placement === 'Far' ? ((pointer.markerType === 'Triangle' || pointer.markerType === 'Arrow') ? x - border : x + border) : ((pointer.markerType === 'InvertedTriangle' || pointer.markerType === 'InvertedArrow') ? x + border : x - border)) + (offset)) :
                        ((pointer.placement === 'Near' ? ((pointer.markerType === 'InvertedTriangle' || pointer.markerType === 'InvertedArrow') ? x + border : x - border) : ((pointer.markerType === 'Triangle' || pointer.markerType === 'Arrow') ? x - border : x + border)) + (offset));
                }
                else {
                    x = (pointer.position === 'Cross' ? line.x - (pointer.markerType === 'Text' ? textSize.width : pointer.width / 2) - offset :
                        ((pointer.position === 'Inside' && !axis.opposedPosition) ||
                            (pointer.position === 'Outside' && axis.opposedPosition)) ?
                            (line.x - line.width / 2 - (pointer.markerType !== 'InvertedTriangle' && pointer.markerType !== 'Triangle' ?
                                (pointer.markerType === 'Text' ? textSize.width : pointer.width) : 0)) - offset : ((line.x + line.width / 2) + offset));
                }
                y = ((helper_2.valueToCoefficient(pointer.currentValue, axis, this.gauge.orientation, range) * line.height) + line.y);
            }
            else {
                if (pointer.position === 'Auto') {
                    y = (!axis.opposedPosition) ? (placement === 'Near') ? label.y - label.height : (placement === 'Center') ? tick.y :
                        line.y : (placement === 'Far') ? label.y : (placement === 'Center') ? tick.y + tick.height : line.y;
                    y = !axis.opposedPosition ? ((pointer.placement === 'Far' ? ((pointer.markerType === 'Triangle' || pointer.markerType === 'Arrow') ? y - border : y + border) : ((pointer.markerType === 'InvertedTriangle' || pointer.markerType === 'InvertedArrow') ? y + border : y - border)) + (offset)) :
                        ((pointer.placement === 'Near' ? ((pointer.markerType === 'InvertedTriangle' || pointer.markerType === 'InvertedArrow') ? y + border : y - border) : ((pointer.markerType === 'Triangle' || pointer.markerType === 'Arrow') ? y - border : y + border)) + (offset));
                }
                else {
                    y = (pointer.position === 'Cross' ? line.y - ((pointer.markerType === 'Text' ? textSize.height : pointer.height) / 2) - offset :
                        ((pointer.position === 'Inside' && !axis.opposedPosition) ||
                            (pointer.position === 'Outside' && axis.opposedPosition)) ?
                            (line.y - line.height / 2 - (pointer.markerType !== 'InvertedTriangle' && pointer.markerType !== 'Triangle' ?
                                (pointer.markerType === 'Text' ? textSize.height : pointer.height) : 0)) - offset : ((line.y + line.height / 2) + offset));
                }
                x = ((helper_2.valueToCoefficient(pointer.currentValue, axis, this.gauge.orientation, range) * line.width) + line.x);
            }
            pointer.bounds = new helper_1.Rect(x, y, pointer.width, pointer.height);
            if (axis.minimum === axis.maximum) {
                pointer.bounds = new helper_1.Rect(0, 0, 0, 0);
                pointer.width = 0;
                pointer.height = 0;
            }
        };
        AxisLayoutPanel.prototype.calculateBarBounds = function (axis, pointer) {
            var x1;
            var x2;
            var y1;
            var y2;
            var height;
            var width;
            var line = axis.lineBounds;
            var padding = 10;
            var range = axis.visibleRange;
            var orientation = this.gauge.orientation;
            var offset = pointer.currentOffset;
            var container = this.gauge.containerBounds;
            if (orientation === 'Vertical') {
                if (pointer.position === 'Auto') {
                    x1 = (container.width > 0) ? container.x + ((container.width / 2) - (pointer.width / 2)) :
                        (!axis.opposedPosition) ? (line.x + padding) : (line.x - pointer.width - padding);
                    x1 += (offset);
                }
                else {
                    x1 = (pointer.position === 'Cross' ? line.x - pointer.width / 2 - offset :
                        ((pointer.position === 'Inside' && !axis.opposedPosition) ||
                            (pointer.position === 'Outside' && axis.opposedPosition)) ?
                            (line.x - line.width / 2 - pointer.width) - offset : ((line.x + line.width / 2) + offset));
                }
                y1 = ((helper_2.valueToCoefficient(pointer.currentValue, axis, orientation, range) * line.height) + line.y);
                y2 = ((helper_2.valueToCoefficient(range.min, axis, orientation, range) * line.height) + line.y);
                height = Math.abs(y2 - y1);
                y1 = (!axis.isInversed) ? y1 : y2;
                width = pointer.width;
            }
            else {
                if (pointer.position === 'Auto') {
                    y1 = (container.height > 0) ? (container.y + (container.height / 2) - (pointer.height) / 2) :
                        (!axis.opposedPosition) ? (line.y + padding) : (line.y - pointer.height - padding);
                    y1 += (offset);
                }
                else {
                    y1 = (pointer.position === 'Cross' ? line.y - pointer.height / 2 - offset :
                        ((pointer.position === 'Inside' && !axis.opposedPosition) ||
                            (pointer.position === 'Outside' && axis.opposedPosition)) ?
                            (line.y - line.height / 2 - pointer.height) - offset : ((line.y + line.height / 2) + offset));
                }
                height = pointer.height;
                x1 = ((helper_2.valueToCoefficient(range.min, axis, orientation, range) * line.width) + line.x);
                x2 = ((helper_2.valueToCoefficient(pointer.currentValue, axis, orientation, range) * line.width) + line.x);
                width = Math.abs(x2 - x1);
                x1 = (!axis.isInversed) ? x1 : x2;
            }
            pointer.bounds = new helper_1.Rect(x1, y1, width, height);
            Iif (axis.minimum === axis.maximum) {
                pointer.bounds = new helper_1.Rect(0, 0, 0, 0);
                pointer.width = 0;
                pointer.height = 0;
            }
        };
        AxisLayoutPanel.prototype.calculateRangesBounds = function (axis) {
            var range;
            var start;
            var end;
            var line = axis.lineBounds;
            var visibleRange = axis.visibleRange;
            var orientation = this.gauge.orientation;
            var startVal;
            var endVal;
            var pointX;
            var pointY;
            var width;
            var height;
            var position;
            var gradientRangeColor;
            var startWidth;
            var endWidth;
            var colors;
            for (var i = 0; i < axis.ranges.length; i++) {
                range = axis.ranges[i];
                if (this.gauge.gradientModule) {
                    gradientRangeColor = this.gauge.gradientModule.getGradientColorString(range);
                }
                Iif (!ej2_base_1.isNullOrUndefined(range.offset) && range.offset.length > 0) {
                    range.currentOffset = helper_1.stringToNumber(range.offset, (this.gauge.orientation === 'Horizontal' ?
                        this.gauge.availableSize.height / 2 : this.gauge.availableSize.width / 2));
                }
                else {
                    range.currentOffset = range.offset;
                }
                start = Math.max(range.start, visibleRange.min);
                end = Math.min(range.end, visibleRange.max);
                if (helper_2.withInRange(null, start, end, visibleRange.max, visibleRange.min, 'range')) {
                    end = Math.max(start, end);
                    start = Math.min(start, range.end);
                    position = range.position;
                    startWidth = range.startWidth;
                    endWidth = range.endWidth;
                    colors = (!ej2_base_1.isNullOrUndefined(this.gauge.rangePalettes) && this.gauge.rangePalettes.length > 0) ? this.gauge.rangePalettes :
                        helper_2.getRangePalette(this.gauge.theme);
                    range.interior = (gradientRangeColor) ? gradientRangeColor :
                        (range.color) ? range.color : colors[i % colors.length];
                    if (this.gauge.orientation === 'Vertical') {
                        pointX = line.x + (range.currentOffset) + (position === 'Cross' ? startWidth / 2 :
                            (position === 'Outside' || position === 'Auto') ?
                                -(line.width / 2) : position === 'Inside' ? line.width / 2 : 0);
                        pointY = (helper_2.valueToCoefficient(end, axis, orientation, visibleRange) * line.height) + line.y;
                        height = (helper_2.valueToCoefficient(start, axis, orientation, visibleRange) * line.height) + line.y;
                        height -= pointY;
                        startVal = !axis.opposedPosition ? (position === 'Inside' ? (pointX + startWidth) : position === 'Cross' ?
                            (pointX - startWidth) : (pointX - startWidth)) : (position === 'Inside' ? (pointX - startWidth) :
                            position === 'Cross' ? (pointX - startWidth) : (pointX + startWidth));
                        endVal = !axis.opposedPosition ? position === 'Inside' ? (pointX + endWidth) : position === 'Cross' ?
                            (pointX - endWidth) : (pointX - endWidth) : position === 'Inside' ? (pointX - endWidth) :
                            position === 'Cross' ? (pointX - endWidth) : (pointX + endWidth);
                        range.path = 'M' + pointX + ' ' + pointY + ' L ' + pointX + ' ' + (pointY + height) +
                            ' L ' + startVal + ' ' + (pointY + height) + ' L ' + endVal + ' ' + pointY +
                            ' L ' + pointX + ' ' + pointY + ' z ';
                    }
                    else {
                        pointX = (helper_2.valueToCoefficient(end, axis, orientation, visibleRange) * line.width) + line.x;
                        pointY = axis.lineBounds.y + (range.currentOffset) + (position === 'Cross' ? startWidth / 2 :
                            (position === 'Outside' || position === 'Auto') ? -(line.height / 2) : position === 'Inside' ? line.height / 2 : 0);
                        width = (helper_2.valueToCoefficient(start, axis, orientation, visibleRange) * line.width) + line.x;
                        width = pointX - width;
                        startVal = !axis.opposedPosition ? position === 'Inside' ? (pointY + startWidth) : position === 'Cross' ?
                            (pointY - startWidth) : (pointY - startWidth) : (position === 'Inside') ? (pointY - startWidth) :
                            position === 'Cross' ? (pointY - startWidth) : (pointY + startWidth);
                        endVal = !axis.opposedPosition ? position === 'Inside' ? (pointY + endWidth) : position === 'Cross' ?
                            (pointY - endWidth) : (pointY - endWidth) : (position === 'Inside') ? (pointY - endWidth) :
                            position === 'Cross' ? (pointY - endWidth) : (pointY + endWidth);
                        range.path = 'M' + pointX + ' ' + pointY + ' L ' + (pointX - width) + ' ' + pointY +
                            ' L ' + (pointX - width) + ' ' + startVal + ' L ' + pointX + ' ' + endVal +
                            ' L ' + pointX + ' ' + pointY + ' z ';
                    }
                }
            }
        };
        AxisLayoutPanel.prototype.checkPreviousAxes = function (currentAxis, axisIndex) {
            var index = axisIndex - 1;
            var prevAxis;
            var isPositive = (index >= 0) ? true : false;
            if (isPositive) {
                prevAxis = this.gauge.axes[index];
                index = (prevAxis.checkAlign.align === currentAxis.checkAlign.align) ? index : this.checkPreviousAxes(currentAxis, index);
            }
            else {
                index = null;
            }
            return index;
        };
        AxisLayoutPanel.prototype.calculateVisibleLabels = function (axis) {
            axis.visibleLabels = [];
            if (axis.minimum !== axis.maximum) {
                var min = axis.visibleRange.min;
                var max = axis.visibleRange.max;
                var interval = axis.visibleRange.interval;
                var argsData = void 0;
                var style = axis.labelStyle;
                var labelSize_1;
                var customLabelFormat = style.format && style.format.match('{value}') !== null;
                var _loop_1 = function (i) {
                    var currentAxisValue = i;
                    Iif (currentAxisValue.toString().indexOf('e') !== -1 && ej2_base_1.isNullOrUndefined(this_1.gauge.format)) {
                        var exponent = parseInt(currentAxisValue.toString().split('-')[1], 10);
                        currentAxisValue = parseInt(currentAxisValue.toFixed(exponent), 10);
                    }
                    argsData = {
                        cancel: false, name: constant_1.axisLabelRender, axis: axis,
                        text: customLabelFormat ? helper_1.textFormatter(style.format, { value: currentAxisValue }, this_1.gauge) :
                            helper_1.formatValue(currentAxisValue, this_1.gauge).toString(),
                        value: currentAxisValue
                    };
                    var axisLabelRenderSuccess = function (argsData) {
                        Eif (!argsData.cancel) {
                            axis.visibleLabels.push(new helper_1.VisibleLabels(argsData.text, currentAxisValue, labelSize_1));
                        }
                    };
                    axisLabelRenderSuccess.bind(this_1);
                    this_1.gauge.trigger(constant_1.axisLabelRender, argsData, axisLabelRenderSuccess);
                };
                var this_1 = this;
                for (var i = min; (i <= max && interval > 0); i += interval) {
                    _loop_1(i);
                }
                var lastLabel = axis.visibleLabels.length ? axis.visibleLabels[axis.visibleLabels.length - 1].value : null;
                var maxVal_1 = axis.visibleRange.max;
                if (lastLabel !== maxVal_1 && axis.showLastLabel === true) {
                    argsData = {
                        cancel: false, name: constant_1.axisLabelRender, axis: axis,
                        text: customLabelFormat ? helper_1.textFormatter(style.format, { value: maxVal_1 }, this.gauge) :
                            helper_1.formatValue(maxVal_1, this.gauge).toString(),
                        value: maxVal_1
                    };
                    var axisLabelRenderSuccess = function (argsData) {
                        labelSize_1 = helper_1.measureText(argsData.text, axis.labelStyle.font);
                        Eif (!argsData.cancel) {
                            axis.visibleLabels.push(new helper_1.VisibleLabels(argsData.text, maxVal_1, labelSize_1));
                        }
                    };
                    axisLabelRenderSuccess.bind(this);
                    this.gauge.trigger(constant_1.axisLabelRender, argsData, axisLabelRenderSuccess);
                }
                this.getMaxLabelWidth(axis);
            }
        };
        AxisLayoutPanel.prototype.getMaxLabelWidth = function (axis) {
            axis.maxLabelSize = new helper_1.Size(0, 0);
            var label;
            for (var i = 0; i < axis.visibleLabels.length; i++) {
                label = axis.visibleLabels[i];
                label.size = helper_1.measureText(label.text, axis.labelStyle.font);
                if (label.size.width > axis.maxLabelSize.width) {
                    axis.maxLabelSize.width = label.size.width;
                }
                if (label.size.height > axis.maxLabelSize.height) {
                    axis.maxLabelSize.height = label.size.height;
                }
            }
        };
        AxisLayoutPanel.prototype.checkThermometer = function () {
            if (this.gauge.container.type === 'Thermometer') {
                this.gauge.axes.map(function (axis) {
                    if (axis.isInversed) {
                        axis.pointers.map(function (pointer) {
                            if (pointer.type === 'Bar') {
                                axis.isInversed = false;
                            }
                        });
                    }
                });
            }
        };
        AxisLayoutPanel.prototype.destroy = function () {
            this.gauge = null;
        };
        return AxisLayoutPanel;
    }());
    exports.AxisLayoutPanel = AxisLayoutPanel;
});