all files / accumulation-chart/renderer/ funnel-series.js

100% Statements 89/89
97.73% Branches 43/44
100% Functions 13/13
100% Lines 86/86
11 statements, 6 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          56×   385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 385×   385× 385× 385× 95×     290×     385× 385× 385× 67× 67×   318× 28× 28× 28×   385× 385× 385× 385× 385× 385× 385× 385× 385× 385× 28× 28×   385× 385× 385× 385×   388×   385× 385× 385× 385× 385× 20×   385× 385× 385× 385× 385× 385×     3272×          
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        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 extendStatics(d, b);
    };
    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", "./triangular-base"], function (require, exports, helper_1, triangular_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var FunnelSeries = (function (_super) {
        __extends(FunnelSeries, _super);
        function FunnelSeries() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        FunnelSeries.prototype.getSegmentData = function (point, series, chart) {
            var lineWidth;
            var topRadius;
            var bottomRadius;
            var endTop;
            var endBottom;
            var minRadius;
            var endMin;
            var bottomY;
            var area = series.triangleSize;
            var offset = 0;
            var extraSpace = (chart.initialClipRect.width - series.triangleSize.width) / 2;
            var emptySpaceAtLeft = extraSpace + chart.initialClipRect.x;
            var seriesTop = chart.initialClipRect.y + (chart.initialClipRect.height - area.height) / 2;
            var top = point.yRatio * area.height;
            var bottom = top + point.heightRatio * area.height;
            var neckSize = series.neckSize;
            lineWidth = neckSize.width + (area.width - neckSize.width) * ((area.height - neckSize.height - top) /
                (area.height - neckSize.height));
            topRadius = (area.width / 2) - lineWidth / 2;
            endTop = topRadius + lineWidth;
            if (bottom > area.height - neckSize.height || area.height === neckSize.height) {
                lineWidth = neckSize.width;
            }
            else {
                lineWidth = neckSize.width + (area.width - neckSize.width) *
                    ((area.height - neckSize.height - bottom) / (area.height - neckSize.height));
            }
            bottomRadius = (area.width / 2) - (lineWidth / 2);
            endBottom = bottomRadius + lineWidth;
            if (top >= area.height - neckSize.height) {
                topRadius = bottomRadius = minRadius = (area.width / 2) - neckSize.width / 2;
                endTop = endBottom = endMin = (area.width / 2) + neckSize.width / 2;
            }
            else if (bottom > (area.height - neckSize.height)) {
                minRadius = bottomRadius = (area.width / 2) - lineWidth / 2;
                endMin = endBottom = minRadius + lineWidth;
                bottomY = area.height - neckSize.height;
            }
            top += seriesTop;
            bottom += seriesTop;
            bottomY += seriesTop;
            var line1 = { x: emptySpaceAtLeft + offset + topRadius, y: top };
            var line2 = { x: emptySpaceAtLeft + offset + endTop, y: top };
            var line4 = { x: emptySpaceAtLeft + offset + endBottom, y: bottom };
            var line5 = { x: emptySpaceAtLeft + offset + bottomRadius, y: bottom };
            var line3 = { x: emptySpaceAtLeft + offset + endBottom, y: bottom };
            var line6 = { x: emptySpaceAtLeft + offset + bottomRadius, y: bottom };
            if (bottomY) {
                line3 = { x: emptySpaceAtLeft + offset + endMin, y: bottomY };
                line6 = { x: emptySpaceAtLeft + offset + minRadius, y: bottomY };
            }
            var polygon = [line1, line2, line3, line4, line5, line6];
            this.setLabelLocation(series, point, polygon);
            var direction = this.findPath(polygon, point, series);
            return direction;
        };
        FunnelSeries.prototype.renderPoint = function (point, series, chart, options, seriesGroup, redraw, previousRadius, previousCenter, pointAnimation) {
            if (!point.visible) {
                helper_1.removeElement(options.id);
                return null;
            }
            var previousDirection;
            var direction = this.getSegmentData(point, series, chart);
            point.midAngle = 0;
            options.d = direction;
            if (pointAnimation && document.getElementById(options.id)) {
                previousDirection = document.getElementById(options.id).getAttribute('d');
            }
            var element = chart.renderer.drawPath(options);
            element.setAttribute('role', 'img');
            element.setAttribute('tabindex', point.index === 0 ? '0' : '-1');
            element.setAttribute('aria-label', (point.x + ':' + point.y + '%. ' + series.name));
            helper_1.appendChildElement(false, seriesGroup, element, redraw, pointAnimation ? pointAnimation : undefined, pointAnimation ? 'x' : undefined, pointAnimation ? 'y' : undefined, undefined, pointAnimation ? previousDirection : undefined, undefined, undefined, undefined, pointAnimation ? chart.duration : undefined);
            if (point.isExplode) {
                chart.accBaseModule.explodePoints(point.index, chart, true);
            }
        };
        FunnelSeries.prototype.getModuleName = function () {
            return 'FunnelSeries';
        };
        FunnelSeries.prototype.destroy = function () {
        };
        return FunnelSeries;
    }(triangular_base_1.TriangularBase));
    exports.FunnelSeries = FunnelSeries;
});