all files / chart/series/ marker-explode.js

99.09% Statements 109/110
92.54% Branches 124/134
100% Functions 17/17
99.07% Lines 106/107
9 statements, 5 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        2399× 2399× 2399× 2399×   4798×     4798× 4798×   165× 165× 22×     455× 455× 353×     375× 375× 375× 375× 375× 375× 375× 292× 292× 292×   292× 292×   60×       83×   82× 82× 82× 180× 180× 43×   137× 134×     137× 133× 133×         374× 374× 141× 128× 10×   128× 177×   116× 116× 116× 117× 117×         128× 128× 177× 177×   128×     374×   67× 67× 67×     374×   117× 117× 117× 117× 117×   117× 117× 117× 117×   117× 117× 117×   117× 234× 234× 234× 234× 234×     79× 79× 24×   79×        
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "../../common/utils/helper", "@syncfusion/ej2-base", "../../chart/utils/get-data", "../../common/utils/helper", "../../common/utils/helper"], function (require, exports, helper_1, ej2_base_1, get_data_1, helper_2, helper_3) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var MarkerExplode = (function (_super) {
        __extends(MarkerExplode, _super);
        function MarkerExplode(chart) {
            var _this = _super.call(this, chart) || this;
            _this.addEventListener();
            _this.elementId = chart.element.id;
            return _this;
        }
        MarkerExplode.prototype.addEventListener = function () {
            Iif (this.chart.isDestroyed) {
                return;
            }
            this.chart.on(ej2_base_1.Browser.touchMoveEvent, this.mouseMoveHandler, this);
            this.chart.on(ej2_base_1.Browser.touchEndEvent, this.mouseUpHandler, this);
        };
        MarkerExplode.prototype.mouseUpHandler = function () {
            var chart = this.chart;
            if (chart.isTouch && !chart.crosshair.enable && !this.isSelected(chart)) {
                this.markerMove(true);
            }
        };
        MarkerExplode.prototype.mouseMoveHandler = function () {
            var chart = this.chart;
            if ((!chart.crosshair.enable || (chart.tooltip.enable)) && (!chart.isTouch || chart.startMove) && !this.isSelected(chart)) {
                this.markerMove(false);
            }
        };
        MarkerExplode.prototype.markerMove = function (remove) {
            var _this = this;
            var chart = this.chart;
            this.currentPoints = [];
            var data;
            var previous;
            var explodeSeries;
            if (!chart.tooltip.shared || !chart.tooltip.enable) {
                data = this.getData();
                previous = this.previousPoints[0];
                explodeSeries = data.series && (data.series.type === 'BoxAndWhisker' || data.series.type === 'Bubble' || data.series.drawType === 'Scatter'
                    || data.series.type === 'Scatter' || (!data.series.isRectSeries && data.series.marker.visible));
                data.lierIndex = this.lierIndex;
                if (data.point && explodeSeries && ((!previous || (previous.point !== data.point)) ||
                    (previous && previous.lierIndex > 3 && previous.lierIndex !== this.lierIndex))) {
                    this.currentPoints.push(data);
                }
            }
            else {
                if (!helper_2.withInBounds(chart.mouseX, chart.mouseY, chart.chartAxisLayoutPanel.seriesClipRect)) {
                    return null;
                }
                Eif (chart.tooltip.enable) {
                    var pointData = chart.chartAreaType === 'PolarRadar' ? this.getData() : null;
                    for (var _i = 0, _a = chart.visibleSeries; _i < _a.length; _i++) {
                        var chartSeries = _a[_i];
                        if (!chartSeries.enableTooltip || chartSeries.category === 'Indicator') {
                            continue;
                        }
                        if (chart.chartAreaType === 'Cartesian' && chartSeries.visible) {
                            data = this.getClosestX(chart, chartSeries);
                        }
                        else if (chart.chartAreaType === 'PolarRadar' && chartSeries.visible && pointData.point !== null) {
                            data = new helper_2.PointData(chartSeries.points[pointData.point.index], chartSeries);
                        }
                        if (data) {
                            this.currentPoints.push(data);
                            data = null;
                        }
                    }
                }
            }
            var length = this.previousPoints.length;
            if (this.currentPoints.length > 0) {
                if (length === 0 || (length > 0 && this.previousPoints[0].point !== this.currentPoints[0].point)) {
                    if (this.previousPoints.length > 0) {
                        this.removeHighlightedMarker();
                    }
                    var _loop_1 = function (data_1) {
                        if (data_1 && data_1.point &&
                            (!data_1.series.isRectSeries || data_1.series.type === 'BoxAndWhisker')) {
                            helper_2.stopTimer(this_1.markerExplode);
                            this_1.isRemove = true;
                            data_1.point.symbolLocations.map(function (location, index) {
                                Eif (data_1.point.marker.visible) {
                                    _this.drawTrackBall(data_1.series, data_1.point, location, index);
                                }
                            });
                        }
                    };
                    var this_1 = this;
                    for (var _b = 0, _c = this.currentPoints; _b < _c.length; _b++) {
                        var data_1 = _c[_b];
                        _loop_1(data_1);
                    }
                    this.previousPoints = ej2_base_1.extend([], this.currentPoints, null, true);
                }
            }
            if (!chart.tooltip.enable && ((this.currentPoints.length === 0 && this.isRemove) || (remove && this.isRemove) ||
                !helper_2.withInBounds(chart.mouseX, chart.mouseY, chart.chartAxisLayoutPanel.seriesClipRect))) {
                this.isRemove = false;
                this.markerExplode = setTimeout(function () {
                    _this.removeHighlightedMarker();
                }, 2000);
            }
            this.currentPoints = [];
        };
        MarkerExplode.prototype.drawTrackBall = function (series, point, location, index) {
            var marker = point.marker;
            var seriesMarker = series.marker;
            var shape = marker.shape || seriesMarker.shape;
            var element = series.symbolElement || series.seriesElement;
            var symbolId = this.elementId + '_Series_' + series.index + '_Point_' + point.index + '_Trackball' +
                (index ? index : '');
            var size = new helper_1.Size((marker.width || seriesMarker.width) + 5, (marker.height || seriesMarker.height) + 5);
            var border = (marker.border || series.border);
            var explodeSeries = (series.type === 'BoxAndWhisker' || series.type === 'Bubble' || series.type === 'Scatter');
            var borderColor = (border.color && border.color !== 'transparent') ? border.color :
                marker.fill || point.interior || (explodeSeries ? point.color : series.interior);
            var colorValue = helper_3.convertHexToColor(helper_3.colorNameToHex(borderColor));
            var borderWidth = marker.border ? marker.border.width : seriesMarker.border.width;
            var markerShadow = series.chart.themeStyle.markerShadow ||
                'rgba(' + colorValue.r + ',' + colorValue.g + ',' + colorValue.b + ',0.2)';
            for (var i = 0; i < 2; i++) {
                var options = new helper_1.PathOption(symbolId + '_' + i, i ? (marker.fill || point.color || (explodeSeries ? series.interior : '#ffffff')) : 'transparent', borderWidth + (i ? 0 : 8), i ? borderColor : markerShadow, (marker.opacity || seriesMarker.opacity), null, null);
                var symbol = helper_1.drawSymbol(location, shape, size, seriesMarker.imageUrl, options, '');
                symbol.setAttribute('style', 'pointer-events:none');
                symbol.setAttribute('class', 'EJ2-Trackball');
                element.appendChild(symbol);
            }
        };
        MarkerExplode.prototype.removeHighlightedMarker = function () {
            var elements = document.getElementsByClassName('EJ2-Trackball');
            for (var i = 0, len = elements.length; i < len; i++) {
                ej2_base_1.remove(elements[0]);
            }
            this.previousPoints = [];
        };
        return MarkerExplode;
    }(get_data_1.ChartData));
    exports.MarkerExplode = MarkerExplode;
});