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

98.86% Statements 87/88
86.05% Branches 37/43
100% Functions 9/9
98.86% Lines 87/88
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     117× 117× 714× 714× 709×       709× 709× 709× 709× 707×             707× 707× 707× 707× 707× 707× 707× 707×   700× 700× 13×     687×   700×   700× 700× 700× 700× 700× 700× 31×     669×     117× 117× 117×     117× 117× 117× 117× 117× 117× 117× 117× 714× 714× 714× 714× 714× 714× 450×   264× 264×   132× 132× 132× 132×   12× 12× 12× 12×   120× 120× 120× 120×       714× 714× 714× 714× 714× 714× 714× 714× 714×       4177×        
define(["require", "exports", "../../common/model/constants"], function (require, exports, constants_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var BarSeries3D = (function () {
        function BarSeries3D() {
        }
        BarSeries3D.prototype.draw = function (series, chart) {
            this.createSegments(series);
            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;
                    if (!argsData.cancel) {
                        this.update(argsData.series, argsData.point, i, chart);
                    }
                    else {
                        point.symbolLocations = null;
                    }
                }
            }
        };
        BarSeries3D.prototype.update = function (series, point, pointIndex, chart) {
            var seriesIndex = chart.visibleSeries.indexOf(series);
            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;
            if (!((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 {
                chart.polygon.createBox(tlfVector, brbVector, chart, pointIndex, '', point.color, null, styleOptions.opacity, chart.requireInvertedAxis, name, chart.chart3D);
            }
        };
        BarSeries3D.prototype.createSegments = function (series) {
            var xValues = series.getXValues(series.visiblePoints);
            var YValues = series.getYValues(series.visiblePoints);
            Iif (xValues == null) {
                return;
            }
            series.isRectSeries = true;
            var sbsInfo = series.getSideBySideInfo(series);
            var depthInfo = series.getSegmentDepth(series);
            var crossValue = 0;
            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 y1 = YValues[i];
                var y2 = crossValue;
                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;
                        break;
                    case 'Bottom':
                        visiblePoints[i].symbolLocations.x = x1 + median;
                        visiblePoints[i].symbolLocations.y = y2 - cons + series.yAxis.visibleRange.min;
                        visiblePoints[i].symbolLocations.z = depthInfo.start + (depthInfo.end - depthInfo.start) / 2;
                        break;
                    default:
                        visiblePoints[i].symbolLocations.x = x1 + median;
                        visiblePoints[i].symbolLocations.y = Math.abs(y2 - y1) / 2 + (series.yAxis.visibleRange.min / 2);
                        visiblePoints[i].symbolLocations.z = depthInfo.start;
                        break;
                }
            }
        };
        BarSeries3D.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);
            }
        };
        BarSeries3D.prototype.destroy = function () {
        };
        BarSeries3D.prototype.getModuleName = function () {
            return 'BarSeries3D';
        };
        return BarSeries3D;
    }());
    exports.BarSeries3D = BarSeries3D;
});