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

100% Statements 75/75
95.83% Branches 23/24
100% Functions 12/12
100% Lines 72/72
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        38×   200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200×   200× 200× 200× 38×     162×     200× 200× 200× 28× 28×   172× 10× 10× 10×   200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 200× 10× 10×   200× 200× 200× 200×   200× 200× 200×   1157×          
/* 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", "./triangular-base"], function (require, exports, 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;
            }
            var points = [];
            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);
            return direction;
        };
        FunnelSeries.prototype.renderPoint = function (point, series, chart, options) {
            var direction = this.getSegmentData(point, series, chart);
            point.midAngle = 0;
            options.d = direction;
        };
        FunnelSeries.prototype.getModuleName = function () {
            return 'FunnelSeries';
        };
        FunnelSeries.prototype.destroy = function (accumulation) {
        };
        return FunnelSeries;
    }(triangular_base_1.TriangularBase));
    exports.FunnelSeries = FunnelSeries;
});