all files / chart3d/series/ stacking-bar-series.js

96.55% Statements 84/87
85.11% Branches 40/47
100% Functions 9/9
96.55% Lines 84/87
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     222× 222× 222× 1074× 1074× 965×       965× 965× 965× 965× 965×               965× 965× 965× 965× 965× 965× 965× 965×     965× 965× 151×     814×   965×   965×   965× 965× 965× 965× 965× 144×   821× 821×     222× 222×     222× 222× 222× 222× 222× 222× 1074× 1074× 1074× 1074× 1074× 1074× 886×   188× 188×   12× 12× 12× 12×     170× 170× 170× 170×       1074× 1074× 1074× 1074× 1074× 1074× 1074× 1074× 1074×       4177×        
define(["require", "exports", "../../common/model/constants"], function (require, exports, constants_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var StackingBarSeries3D = (function () {
        function StackingBarSeries3D() {
        }
        StackingBarSeries3D.prototype.draw = function (series, chart) {
            this.createSegments(series);
            series.isRectSeries = true;
            for (var i = 0; i < series.visiblePoints.length; i++) {
                var point = series.visiblePoints[i];
                if (point.visible) {
                    var argsData = {
                        cancel: false, series: series, point: point,
                        fill: series.setPointColor(point, series.interior)
                    };
                    chart.trigger(constants_1.pointRender, argsData);
                    point.color = argsData.fill;
                    point.plans = null;
                    Eif (!argsData.cancel) {
                        this.update(argsData.series, argsData.point, i, chart);
                    }
                    else {
                        point.symbolLocations = null;
                    }
                }
            }
        };
        StackingBarSeries3D.prototype.update = function (series, point, pointIndex, chart) {
            var seriesIndex = series.index;
            var left = point.left;
            var right = point.right;
            var bottom = series.yAxis.valueType === 'Logarithmic' ? Math.pow(series.yAxis.logBase, series.yAxis.visibleRange.min) : series.yAxis.visibleRange.min;
            var top = series.yAxis.valueType === 'Logarithmic' ? Math.pow(series.yAxis.logBase, series.yAxis.visibleRange.max) : series.yAxis.visibleRange.max;
            var xStart = series.xAxis.visibleRange.min;
            var xEnd = series.xAxis.visibleRange.max;
            Iif (!((left >= xStart) && (left <= xEnd)) || !((right >= xStart) && (right <= xEnd))) {
                return;
            }
            var topValue;
            if (point.top < 0) {
                topValue = (point.top > bottom) ? point.top : bottom;
            }
            else {
                topValue = (series.yAxis.valueType && series.yAxis.valueType.toLowerCase() === 'logarithmic') ? point.top : (point.top < top) ? point.top : top;
            }
            var tlpoint = chart.svg3DRenderer.transform3DToVisible(series, (point.left > xStart) ? point.left :
                xStart, topValue, chart);
            var rbpoint = chart.svg3DRenderer.transform3DToVisible(series, (xEnd > point.right) ? point.right :
                xEnd, (bottom > point.bottom) ? bottom : point.bottom, chart);
            var tlfVector = chart.vector.vector3D(Math.min(tlpoint.x, rbpoint.x), Math.min(tlpoint.y, rbpoint.y), point.startDepth);
            var brbVector = chart.vector.vector3D(Math.max(tlpoint.x, rbpoint.x), Math.max(tlpoint.y, rbpoint.y), point.endDepth);
            var styleOptions = series.setStyle(series);
            var name = 'region' + '-series-' + seriesIndex + '-point-' + pointIndex;
            if (series.columnFacet === 'Cylinder') {
                chart.polygon.createCylinder(tlfVector, brbVector, chart, pointIndex, series.type, '', point.color, null, styleOptions.opacity, name, chart.chart3D);
            }
            else Eif (series.columnFacet === 'Rectangle') {
                chart.polygon.createBox(tlfVector, brbVector, chart, pointIndex, '', point.color, null, styleOptions.opacity, chart.requireInvertedAxis, name, chart.chart3D);
            }
        };
        StackingBarSeries3D.prototype.createSegments = function (series) {
            var xValues = series.getXValues(series.visiblePoints);
            Iif (xValues == null) {
                return;
            }
            var sbsInfo = series.getSideBySideInfo(series);
            var depthInfo = series.getSegmentDepth(series);
            var median = sbsInfo.delta / 2;
            var visiblePoints = series.visiblePoints;
            var cons = 0.2;
            for (var i = 0; i < visiblePoints.length; i++) {
                var x1 = xValues[i] + sbsInfo.start;
                var x2 = xValues[i] + sbsInfo.end;
                var y2 = series.stackedValues.startValues[i];
                var y1 = series.stackedValues.endValues[i];
                this.setData(x1, y1, x2, y2, depthInfo.start, depthInfo.end, series, visiblePoints[i]);
                if (!series.dataLabel.visible) {
                    continue;
                }
                visiblePoints[i].symbolLocations = { x: 0, y: 0, z: 0 };
                switch (series.dataLabel.position) {
                    case 'Top':
                        visiblePoints[i].symbolLocations.x = x1 + median;
                        visiblePoints[i].symbolLocations.y = y1;
                        visiblePoints[i].symbolLocations.z = depthInfo.start + (depthInfo.delta / 2);
                        break;
                    case 'Bottom':
                        visiblePoints[i].symbolLocations.x = x1 + median;
                        visiblePoints[i].symbolLocations.y = y2 - cons;
                        visiblePoints[i].symbolLocations.z = depthInfo.start + (depthInfo.end - depthInfo.start) / 2;
                        break;
                    default:
                        visiblePoints[i].symbolLocations.x = x1 + median;
                        visiblePoints[i].symbolLocations.y = y1 + (y2 - y1) / 2;
                        visiblePoints[i].symbolLocations.z = depthInfo.start;
                        break;
                }
            }
        };
        StackingBarSeries3D.prototype.setData = function (x1, y1, x2, y2, start, end, series, point) {
            point.left = x1;
            point.bottom = y2;
            point.top = y1;
            point.right = x2;
            point.startDepth = start;
            point.endDepth = end;
            point.xRange = series.getDoubleRange(point.left, point.right);
            Eif (!isNaN(point.top) && !isNaN(point.bottom)) {
                point.yRange = series.getDoubleRange(point.top, point.bottom);
            }
        };
        StackingBarSeries3D.prototype.destroy = function () {
        };
        StackingBarSeries3D.prototype.getModuleName = function () {
            return 'StackingBarSeries3D';
        };
        return StackingBarSeries3D;
    }());
    exports.StackingBarSeries3D = StackingBarSeries3D;
});