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

98.39% Statements 61/62
96.15% Branches 25/26
100% Functions 7/7
98.39% Lines 61/62
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     105× 105× 105× 105× 105× 105× 105× 105× 105× 105× 105× 105× 105× 12× 30× 30× 24×     12× 12× 12×     93× 93×   105× 905× 905× 905× 905×   808× 88×     720×   808× 808×           808× 808× 808× 808× 808× 808× 808× 808×                         20665×   19× 19× 19× 19× 19× 151× 151×   145× 145×          
define(["require", "exports", "../../common/utils/helper", "../../common/model/constants"], function (require, exports, helper_1, constants_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var BubbleSeries = (function () {
        function BubbleSeries() {
        }
        BubbleSeries.prototype.render = function (series, xAxis, yAxis, isInverted) {
            var marker = series.marker;
            var visiblePoints = series.points;
            var shapeOption;
            var argsData;
            var segmentRadius;
            var radius;
            var value = Math.max(series.chart.initialClipRect.height, series.chart.initialClipRect.width);
            var percentChange = value / 100;
            var maxRadius = series.maxRadius * percentChange;
            var minRadius = series.minRadius * percentChange;
            var maximumSize = null;
            var maxValue = null;
            if ((series.maxRadius === null || series.minRadius === null)) {
                for (var _i = 0, _a = series.chart.visibleSeries; _i < _a.length; _i++) {
                    var value_1 = _a[_i];
                    if (value_1.type === 'Bubble' && value_1.visible === true && (value_1.maxRadius === null || value_1.minRadius === null)) {
                        maximumSize = value_1.sizeMax > maximumSize ? value_1.sizeMax : maximumSize;
                    }
                }
                maxValue = (value / 5) / 2;
                minRadius = maxRadius = 1;
                radius = maxValue * maxRadius;
            }
            else {
                maximumSize = series.sizeMax;
                radius = maxRadius - minRadius;
            }
            for (var _b = 0, visiblePoints_1 = visiblePoints; _b < visiblePoints_1.length; _b++) {
                var bubblePoint = visiblePoints_1[_b];
                bubblePoint.symbolLocations = [];
                bubblePoint.regions = [];
                if (bubblePoint.visible &&
                    helper_1.withInRange(visiblePoints[bubblePoint.index - 1], bubblePoint, visiblePoints[bubblePoint.index + 1], series)) {
                    if ((series.maxRadius === null || series.minRadius === null)) {
                        segmentRadius = radius * Math.abs(+bubblePoint.size / maximumSize);
                    }
                    else {
                        segmentRadius = minRadius + radius * Math.abs(+bubblePoint.size / maximumSize);
                    }
                    segmentRadius = segmentRadius || minRadius;
                    argsData = {
                        cancel: false, name: constants_1.pointRender, series: series, point: bubblePoint,
                        fill: series.setPointColor(bubblePoint, series.interior),
                        border: series.setBorderColor(bubblePoint, { width: series.border.width, color: series.border.color }),
                        height: 2 * segmentRadius, width: 2 * segmentRadius
                    };
                    series.chart.trigger(constants_1.pointRender, argsData);
                    Eif (!argsData.cancel) {
                        bubblePoint.symbolLocations.push(helper_1.getPoint(bubblePoint.xValue, bubblePoint.yValue, xAxis, yAxis, isInverted));
                        bubblePoint.color = argsData.fill;
                        shapeOption = new helper_1.PathOption(series.chart.element.id + '_Series_' + series.index + '_Point_' + bubblePoint.index, argsData.fill, argsData.border.width, argsData.border.color, series.opacity, null);
                        series.seriesElement.appendChild(helper_1.drawSymbol(bubblePoint.symbolLocations[0], 'Circle', new helper_1.Size(argsData.width, argsData.height), marker.imageUrl, shapeOption, bubblePoint.x.toString() + ':' + bubblePoint.yValue.toString()));
                        bubblePoint.regions.push(new helper_1.Rect(bubblePoint.symbolLocations[0].x - segmentRadius, bubblePoint.symbolLocations[0].y - segmentRadius, 2 * segmentRadius, 2 * segmentRadius));
                        bubblePoint.marker = {
                            border: argsData.border, fill: argsData.fill,
                            height: argsData.height, visible: true,
                            shape: 'Circle', width: argsData.width
                        };
                    }
                    else {
                        bubblePoint.marker = { visible: false };
                    }
                }
            }
        };
        BubbleSeries.prototype.destroy = function (chart) {
        };
        BubbleSeries.prototype.getModuleName = function () {
            return 'BubbleSeries';
        };
        BubbleSeries.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 bubblePoint = _a[_i];
                if (!bubblePoint.symbolLocations.length) {
                    continue;
                }
                helper_1.markerAnimate(rectElements[count], delay, duration, series, bubblePoint.index, bubblePoint.symbolLocations[0], false);
                count++;
            }
        };
        return BubbleSeries;
    }());
    exports.BubbleSeries = BubbleSeries;
});