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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 101× 1× 113× 113× 113× 113× 113× 7× 113× 113× 113× 1× 108× 108× 108× 108× 108× 108× 108× 634× 634× 628× 628× 628× 628× 1× 643× 643× 643× 643× 643× 643× 643× 1× 12× 12× 12× 12× 12× 12× 12× 7× 12× 12× 12× 5× 5× 5× 5× 5× 5× 12× 7× 7× 7× 7× 7× 7× 7× 7× 7× 7× 7× 12× 1× 643× 643× 643× 643× 4739× 4713× 643× 4713× 643× 12× 631× 3280× 3280× 2649× 643× 1× 113× 113× 113× 113× 113× 113× 44× 1× 1× | /* 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", "@syncfusion/ej2-svg-base", "../../common/utils/helper", "./accumulation-base"], function (require, exports, ej2_svg_base_1, helper_1, accumulation_base_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var TriangularBase = (function (_super) { __extends(TriangularBase, _super); function TriangularBase() { return _super !== null && _super.apply(this, arguments) || this; } TriangularBase.prototype.initProperties = function (chart, series) { var actualChartArea = chart.initialClipRect; series.triangleSize = new ej2_svg_base_1.Size(helper_1.stringToNumber(series.width, actualChartArea.width), helper_1.stringToNumber(series.height, actualChartArea.height)); series.neckSize = new ej2_svg_base_1.Size(helper_1.stringToNumber(series.neckWidth, actualChartArea.width), helper_1.stringToNumber(series.neckHeight, actualChartArea.height)); this.defaultLabelBound(series, series.dataLabel.visible, series.dataLabel.position, chart); if (series.explodeOffset === '30%') { series.explodeOffset = '25px'; } chart.explodeDistance = helper_1.stringToNumber(series.explodeOffset, actualChartArea.width); var points = series.points; this.initializeSizeRatio(points, series); }; TriangularBase.prototype.initializeSizeRatio = function (points, series, reverse) { if (reverse === void 0) { reverse = false; } var sumOfPoints = series.sumOfPoints; var gapRatio = Math.min(Math.max(series.gapRatio, 0), 1); var coEff = (sumOfPoints !== 0) ? 1 / (sumOfPoints * (1 + gapRatio / (1 - gapRatio))) : 0; var spacing = gapRatio / (points.length - 1); var y = 0; for (var i = points.length - 1; i >= 0; i--) { var index = reverse ? points.length - 1 - i : i; if (points[index].visible) { var height = coEff * points[index].y; points[index].yRatio = y; points[index].heightRatio = height; y += height + spacing; } } }; TriangularBase.prototype.setLabelLocation = function (series, point, points) { var last = points.length - 1; var bottom = series.type === 'Funnel' ? points.length - 2 : points.length - 1; var x = (points[0].x + points[bottom].x) / 2; var right = (points[1].x + points[bottom - 1].x) / 2; point.region = new ej2_svg_base_1.Rect(x, points[0].y, right - x, points[bottom].y - points[0].y); point.symbolLocation = { x: point.region.x + point.region.width / 2, y: point.region.y + point.region.height / 2 }; point.labelOffset = { x: point.symbolLocation.x - (points[0].x + points[last].x) / 2, y: point.symbolLocation.y - (points[0].y + points[last].y) / 2 }; }; TriangularBase.prototype.getPath = function (locations, point, path, firstIndex, lastIndex, series) { var length = series.points.length; var borderRadius = series.borderRadius; var min = Math.min(point.region.width, point.region.height); var funnelMinimum = Math.min(series.neckSize.height, series.neckSize.width); Iif (funnelMinimum === 0) { funnelMinimum = series.neckSize.height === 0 && series.neckSize.width === 0 ? point.region.height : (series.neckSize.width === 0 ? series.neckSize.height : series.neckSize.width); } borderRadius = borderRadius > min / 2 ? min / 2 : borderRadius; if (series.type === 'Funnel') { borderRadius = (borderRadius > funnelMinimum / 2) ? funnelMinimum / 2 : borderRadius; } var angle = Math.atan2(locations[1].x - locations[2].x, locations[1].y - locations[2].y); var temp = borderRadius; if (series.type === 'Pyramid') { borderRadius = (point.index === lastIndex && length !== 1 && firstIndex !== lastIndex) ? 0 : borderRadius; path += (locations[0].x - (temp * Math.sin(-angle))) + ' ' + (locations[0].y + (-temp * Math.cos(angle))) + ' Q' + locations[0].x + ' ' + locations[0].y + ' ' + (locations[0].x + (borderRadius * Math.sin(-angle))) + ' ' + (locations[0].y + (-borderRadius * Math.cos(-angle))); path += ' L' + (locations[1].x + (borderRadius * Math.sin(-angle))) + ' ' + (locations[1].y + (-borderRadius * Math.cos(angle))); borderRadius = point.index === lastIndex ? temp : 0; path += ' L' + (locations[2].x - (temp * Math.sin(-angle))) + ' ' + (locations[2].y - (-temp * Math.cos(angle))) + ' Q' + locations[2].x + ' ' + locations[2].y + ' ' + (locations[2].x - borderRadius) + ' ' + locations[2].y; path += ' L' + (locations[3].x + borderRadius) + ' ' + locations[3].y + ' Q' + locations[3].x + ' ' + locations[3].y + ' ' + (locations[3].x + (temp * Math.sin(-angle))) + ' ' + (locations[3].y - (-temp * Math.cos(angle))); } if (series.type === 'Funnel') { borderRadius = (point.index === firstIndex && length !== 1 && firstIndex !== lastIndex) ? 0 : borderRadius; path += locations[0].x + (-(borderRadius * Math.sin(-angle))) + ' ' + (locations[0].y + (-borderRadius * Math.cos(angle))) + ' Q' + locations[0].x + ' ' + locations[0].y + ' ' + (locations[0].x + borderRadius) + ' ' + locations[0].y; path += ' L' + (locations[1].x - borderRadius) + ' ' + locations[1].y + ' Q' + locations[1].x + ' ' + locations[1].y + ' ' + (locations[1].x - ((borderRadius * Math.sin(angle)))) + ' ' + (locations[1].y + (-borderRadius * Math.cos(angle))); borderRadius = point.index === firstIndex ? temp : 0; Iif (series.neckWidth === '0%') { var middle = (locations[5].x + (locations[3].x - locations[5].x) / 2); path += ' L' + (locations[2].x + (-borderRadius * Math.sin(-angle))) + ' ' + (locations[2].y - (-borderRadius * Math.cos(angle))) + ' Q' + middle + ' ' + locations[2].y + ' ' + (locations[5].x - (-borderRadius * Math.sin(-angle))) + ' ' + (locations[2].y - (-borderRadius * Math.cos(angle))); } else { path = series.neckHeight !== '0%' && locations[2].y !== locations[3].y ? path += ' L' + locations[2].x + ' ' + (locations[2].y) : path; var tempX = series.neckHeight === '0%' ? ((borderRadius * Math.sin(-angle))) : 0; var tempY = series.neckHeight === '0%' ? (-borderRadius * Math.cos(angle)) : borderRadius; path += ' L' + (locations[3].x - (tempX)) + ' ' + (locations[3].y - (tempY)) + ' Q' + locations[3].x + ' ' + locations[3].y + ' ' + (locations[3].x - tempY) + ' ' + locations[3].y; path += ' L' + (locations[4].x + tempY) + ' ' + locations[4].y + ' Q' + locations[4].x + ' ' + locations[4].y + ' ' + (locations[4 + 1].x + tempX) + ' ' + (locations[4].y - tempY); path = series.neckHeight !== '0%' && locations[4].y !== locations[5].y ? path += ' L' + locations[5].x + ' ' + (locations[5].y) : path; } } return path; }; TriangularBase.prototype.findPath = function (locations, point, series) { var path = 'M '; var firstIndex = -1; var lastIndex = -1; for (var index = 0; index < series.points.length; index++) { if (series.points[index].visible) { if (firstIndex === -1) { firstIndex = index; } lastIndex = index; } } if (series.borderRadius && (point.index === lastIndex || point.index === firstIndex)) { path = this.getPath(locations, point, path, firstIndex, lastIndex, series); } else { for (var i = 0; i < locations.length; i++) { path += locations[i].x + ' ' + locations[i].y; if (i !== locations.length - 1) { path += ' L '; } } } return path + ' Z '; }; TriangularBase.prototype.defaultLabelBound = function (series, visible, position, chart) { var x = (chart.initialClipRect.width - series.triangleSize.width) / 2; var y = (chart.initialClipRect.height - series.triangleSize.height) / 2; var accumulationBound = new ej2_svg_base_1.Rect(x, y, series.triangleSize.width, series.triangleSize.height); series.labelBound = new ej2_svg_base_1.Rect(accumulationBound.x, accumulationBound.y, accumulationBound.width + accumulationBound.x, accumulationBound.height + accumulationBound.y); series.accumulationBound = accumulationBound; if (visible && position === 'Outside') { series.labelBound = new ej2_svg_base_1.Rect(Infinity, Infinity, -Infinity, -Infinity); } }; return TriangularBase; }(accumulation_base_1.AccumulationBase)); exports.TriangularBase = TriangularBase; }); |