all files / chart/series/ scatter-series.js

97.03% Statements 98/101
91.04% Branches 61/67
100% Functions 12/12
97.03% Lines 98/101
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     288× 288× 288× 288× 288×       288× 5041× 5041×     5048× 5048× 5048× 5048× 5048× 5048× 5035×           5035× 5035× 4954× 4954× 4954×     81×                       578×   289× 289× 289× 289× 289× 289× 289× 289× 289× 289× 289× 289× 289× 5051× 5051× 4777×   5051× 5051× 5051× 5048× 5048× 5048×     289× 289× 5048× 5048×       5048×     289×   4954× 4954× 4954× 4954× 4954× 4954×   4954× 202× 202× 202× 202×       4954× 4954× 4954× 4954×           26× 26× 26× 26× 26× 409× 409× 14×   395× 395×     41538×          
define(["require", "exports", "../../common/utils/helper", "../../common/utils/helper", "@syncfusion/ej2-svg-base", "../../common/model/constants", "@syncfusion/ej2-base"], function (require, exports, helper_1, helper_2, ej2_svg_base_1, constants_1, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ScatterSeries = (function () {
        function ScatterSeries() {
        }
        ScatterSeries.prototype.render = function (series, xAxis, yAxis, isInverted) {
            series.isRectSeries = false;
            var marker = series.marker;
            var visiblePoints = this.enableComplexProperty(series);
            var getCoordinate = series.chart.chartAreaType === 'PolarRadar' ? helper_2.TransformToVisible : helper_1.getPoint;
            var scatterBorder = {
                width: this.isLineShapeMarker(marker.shape) ? series.width : series.border.width,
                color: this.isLineShapeMarker(marker.shape) ? series.interior : series.border.color
            };
            for (var _i = 0, visiblePoints_1 = visiblePoints; _i < visiblePoints_1.length; _i++) {
                var point = visiblePoints_1[_i];
                this.renderPoint(series, point, isInverted, getCoordinate, scatterBorder, visiblePoints);
            }
        };
        ScatterSeries.prototype.renderPoint = function (series, point, isInverted, getCoordinate, scatterBorder, visiblePoints) {
            var redraw = series.chart.redraw;
            var argsData;
            var startLocation = (redraw && point.symbolLocations) ? point.symbolLocations[0] : null;
            point.symbolLocations = [];
            point.regions = [];
            if (point.visible && helper_1.withInRange(visiblePoints[point.index - 1], point, visiblePoints[point.index + 1], series)) {
                argsData = {
                    cancel: false, name: constants_1.pointRender, series: series, point: point,
                    fill: series.setPointColor(point, series.interior),
                    border: series.setBorderColor(point, { width: scatterBorder.width, color: scatterBorder.color }),
                    height: series.marker.height, width: series.marker.width, shape: series.marker.shape
                };
                series.chart.trigger(constants_1.pointRender, argsData);
                if (!argsData.cancel) {
                    point.symbolLocations.push(getCoordinate(point.xValue, point.yValue, series.xAxis, series.yAxis, isInverted, series));
                    point.color = argsData.fill;
                    this.refresh(series, point, argsData, startLocation);
                }
                else {
                    point.marker = { visible: true };
                }
            }
        };
        ScatterSeries.prototype.updateDirection = function (series, point, isInverted) {
            var marker = series.marker;
            var visiblePoints = this.enableComplexProperty(series);
            var getCoordinate = series.chart.chartAreaType === 'PolarRadar' ? helper_2.TransformToVisible : helper_1.getPoint;
            var scatterBorder = {
                width: this.isLineShapeMarker(marker.shape) ? series.width : series.border.width,
                color: this.isLineShapeMarker(marker.shape) ? series.interior : series.border.color
            };
            for (var i = 0; i < point.length; i++) {
                this.renderPoint(series, series.points[point[i]], isInverted, getCoordinate, scatterBorder, visiblePoints);
                Iif (series.marker.dataLabel.visible && series.chart.dataLabelModule) {
                    series.chart.dataLabelModule.commonId = series.chart.element.id + '_Series_' + series.index + '_Point_';
                    series.chart.dataLabelModule.renderDataLabel(series, series.points[point[i]], null, series.marker.dataLabel);
                }
            }
        };
        ScatterSeries.prototype.isLineShapeMarker = function (shape) {
            return shape === 'HorizontalLine' || shape === 'VerticalLine' || shape === 'Cross';
        };
        ScatterSeries.prototype.enableComplexProperty = function (series) {
            var tempPoints2 = [];
            var tempPoints = [];
            var yVisibleRange = series.yAxis.visibleRange;
            var xVisibleRange = series.xAxis.visibleRange;
            var areaBounds = series.clipRect;
            var seriesPoints = series.points;
            var yTolerance = Math.abs(yVisibleRange.delta / areaBounds.height);
            var xTolerance = Math.abs(xVisibleRange.delta / areaBounds.width);
            var prevYValue = (seriesPoints[0] && seriesPoints[0].y > yTolerance) ? 0 : yTolerance;
            var prevXValue = (seriesPoints[0] && seriesPoints[0].x > xTolerance) ? 0 : xTolerance;
            var yVal = 0;
            var xVal = 0;
            for (var _i = 0, seriesPoints_1 = seriesPoints; _i < seriesPoints_1.length; _i++) {
                var currentPoint = seriesPoints_1[_i];
                if (!currentPoint.symbolLocations) {
                    currentPoint.symbolLocations = [];
                }
                yVal = currentPoint.yValue ? currentPoint.yValue : yVisibleRange.min;
                xVal = currentPoint.xValue ? currentPoint.xValue : xVisibleRange.min;
                if (Math.abs(prevYValue - yVal) >= yTolerance || Math.abs(prevXValue - xVal) >= xTolerance) {
                    tempPoints.push(currentPoint);
                    prevYValue = yVal;
                    prevXValue = xVal;
                }
            }
            var currentTempPoint;
            for (var i = 0; i < tempPoints.length; i++) {
                currentTempPoint = tempPoints[i];
                Iif (ej2_base_1.isNullOrUndefined(currentTempPoint.x) || currentTempPoint.x === '') {
                    continue;
                }
                else {
                    tempPoints2.push(currentTempPoint);
                }
            }
            return tempPoints2;
        };
        ScatterSeries.prototype.refresh = function (series, point, argsData, startLocation) {
            var chart = series.chart;
            var circlePath;
            var previousPath;
            var marker = series.marker;
            var imageURL = argsData.point.marker.imageUrl || marker.imageUrl;
            var shapeOption = new ej2_svg_base_1.PathOption(chart.element.id + '_Series_' + series.index + '_Point_' + point.index, argsData.fill, argsData.border.width, (series.chart.enableCanvas && !argsData.border.color) ? argsData.fill :
                argsData.border.color, series.opacity, series.border.dashArray);
            if (chart.redraw && helper_1.getElement(shapeOption.id)) {
                circlePath = argsData.shape === 'Circle' ? 'c' : '';
                previousPath = helper_1.getElement(shapeOption.id).getAttribute('d');
                var scatterElement = helper_1.getElement(shapeOption.id);
                startLocation = {
                    x: +scatterElement.getAttribute(circlePath + 'x'), y: +scatterElement.getAttribute(circlePath + 'y')
                };
            }
            var element = helper_1.drawSymbol(point.symbolLocations[0], argsData.shape, new ej2_svg_base_1.Size(argsData.width, argsData.height), imageURL, shapeOption, point.x.toString() + ':' + point.yValue.toString(), series.chart.renderer, series.clipRect);
            helper_2.appendChildElement(series.chart.enableCanvas, series.seriesElement, element, chart.redraw, true, circlePath + 'x', circlePath + 'y', startLocation, previousPath, false, false, null, chart.duration, true);
            point.regions.push(new ej2_svg_base_1.Rect(point.symbolLocations[0].x - marker.width, point.symbolLocations[0].y - marker.height, 2 * marker.width, 2 * marker.height));
            point.marker = {
                border: argsData.border, fill: argsData.fill,
                height: argsData.height, visible: true,
                width: argsData.width, shape: argsData.shape, imageUrl: imageURL
            };
        };
        ScatterSeries.prototype.doAnimation = function (series) {
            var duration = series.animation.duration;
            var delay = series.animation.delay;
            var rectElements = series.seriesElement.childNodes;
            var count = 1;
            for (var _i = 0, _a = series.points; _i < _a.length; _i++) {
                var point = _a[_i];
                if (!point.symbolLocations.length || !rectElements[count]) {
                    continue;
                }
                helper_2.markerAnimate(rectElements[count], delay, duration, series, point.index, point.symbolLocations[0], false);
                count++;
            }
        };
        ScatterSeries.prototype.getModuleName = function () {
            return 'ScatterSeries';
        };
        ScatterSeries.prototype.destroy = function () {
        };
        return ScatterSeries;
    }());
    exports.ScatterSeries = ScatterSeries;
});