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 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 378× 1× 180× 180× 180× 180× 180× 180× 180× 180× 180× 180× 1× 180× 180× 180× 180× 180× 180× 180× 1× 540× 540× 540× 540× 540× 1× 180× 180× 180× 180× 16× 1× 360× 360× 360× 360× 360× 360× 360× 360× 360× 360× 360× 360× 360× 360× 360× 360× 352× 360× 360× 1032× 1032× 1024× 360× 360× 360× 1× 2816× 2816× 1× 1958× 1958× 1958× 1958× 1778× 180× 1× 1778× 1× 180× 1× 7× 7× 7× 7× 7× 7× 7× 346× 346× 7× 7× 7× 7× 1× 1× | /* 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", "@syncfusion/ej2-base", "../../common/utils/helper", "../../common/model/constants", "./accumulation-base"], function (require, exports, ej2_base_1, helper_1, constants_1, accumulation_base_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var PieBase = (function (_super) { __extends(PieBase, _super); function PieBase() { return _super !== null && _super.apply(this, arguments) || this; } PieBase.prototype.initProperties = function (chart, series) { this.accumulation = chart; var size = Math.min(chart.initialClipRect.width, chart.initialClipRect.height); this.initAngles(series); this.radius = helper_1.stringToNumber(series.radius, size / 2); this.innerRadius = helper_1.stringToNumber(series.innerRadius, this.radius); this.labelRadius = series.dataLabel.position === 'Inside' ? (((this.radius - this.innerRadius) / 2) + this.innerRadius) : (this.radius + helper_1.stringToNumber(series.dataLabel.connectorStyle.length || '4%', size / 2)); chart.explodeDistance = series.explode ? helper_1.stringToNumber(series.explodeOffset, this.radius) : 0; this.findCenter(chart, series); this.defaultLabelBound(series, series.dataLabel.visible, series.dataLabel.position); this.totalAngle -= 0.001; }; PieBase.prototype.findCenter = function (accumulation, series) { this.accumulation = accumulation; this.center = { x: helper_1.stringToNumber('50%', accumulation.initialClipRect.width) + (accumulation.initialClipRect.x), y: helper_1.stringToNumber('50%', accumulation.initialClipRect.height) + (accumulation.initialClipRect.y) }; var accumulationRect = this.getSeriesBound(series); var accumulationRectCenter = new helper_1.ChartLocation(accumulationRect.x + accumulationRect.width / 2, accumulationRect.y + accumulationRect.height / 2); this.center.x += (this.center.x - accumulationRectCenter.x); this.center.y += (this.center.y - accumulationRectCenter.y); this.accumulation.center = this.center; }; PieBase.prototype.initAngles = function (series) { var endAngle = ej2_base_1.isNullOrUndefined(series.endAngle) ? series.startAngle : series.endAngle; this.totalAngle = (endAngle - series.startAngle) % 360; this.startAngle = series.startAngle - 90; this.totalAngle = this.totalAngle <= 0 ? (360 + this.totalAngle) : this.totalAngle; this.startAngle = (this.startAngle < 0 ? (this.startAngle + 360) : this.startAngle) % 360; }; PieBase.prototype.defaultLabelBound = function (series, visible, position) { var accumulationBound = this.getSeriesBound(series); series.accumulationBound = accumulationBound; series.labelBound = new helper_1.Rect(accumulationBound.x, accumulationBound.y, accumulationBound.width + accumulationBound.x, accumulationBound.height + accumulationBound.y); if (visible && position === 'Outside') { series.labelBound = new helper_1.Rect(Infinity, Infinity, -Infinity, -Infinity); } }; PieBase.prototype.getSeriesBound = function (series) { var rect = new helper_1.Rect(Infinity, Infinity, -Infinity, -Infinity); this.initAngles(series); var start = this.startAngle; var total = this.totalAngle; var end = (this.startAngle + total) % 360; end = (end === 0) ? 360 : end; series.findMaxBounds(rect, this.getRectFromAngle(start)); series.findMaxBounds(rect, this.getRectFromAngle(end)); series.findMaxBounds(rect, new helper_1.Rect(this.center.x, this.center.y, 0, 0)); var nextQuandrant = (Math.floor(start / 90) * 90 + 90) % 360; var lastQuadrant = (Math.floor(end / 90) * 90) % 360; lastQuadrant = (lastQuadrant === 0) ? 360 : lastQuadrant; Eif (total >= 90 || lastQuadrant === nextQuandrant) { series.findMaxBounds(rect, this.getRectFromAngle(nextQuandrant)); series.findMaxBounds(rect, this.getRectFromAngle(lastQuadrant)); } if (start === 0 || (start + total >= 360)) { series.findMaxBounds(rect, this.getRectFromAngle(0)); } var length = nextQuandrant === lastQuadrant ? 0 : Math.floor(total / 90); for (var i = 1; i < length; i++) { nextQuandrant = nextQuandrant + 90; if ((nextQuandrant < lastQuadrant || end < start) || total === 360) { series.findMaxBounds(rect, this.getRectFromAngle(nextQuandrant)); } } rect.width -= rect.x; rect.height -= rect.y; return rect; }; PieBase.prototype.getRectFromAngle = function (angle) { var location = helper_1.degreeToLocation(angle, this.radius, this.center); return new helper_1.Rect(location.x, location.y, 0, 0); }; PieBase.prototype.getPathArc = function (center, start, end, radius, innerRadius) { var degree = end - start; degree = degree < 0 ? (degree + 360) : degree; var flag = (degree < 180) ? 0 : 1; if (!innerRadius && innerRadius === 0) { return this.getPiePath(center, helper_1.degreeToLocation(start, radius, center), helper_1.degreeToLocation(end, radius, center), radius, flag); } else { return this.getDoughnutPath(center, helper_1.degreeToLocation(start, radius, center), helper_1.degreeToLocation(end, radius, center), radius, helper_1.degreeToLocation(start, innerRadius, center), helper_1.degreeToLocation(end, innerRadius, center), innerRadius, flag); } }; PieBase.prototype.getPiePath = function (center, start, end, radius, clockWise) { return 'M ' + center.x + ' ' + center.y + ' L ' + start.x + ' ' + start.y + ' A ' + radius + ' ' + radius + ' 0 ' + clockWise + ' 1 ' + end.x + ' ' + end.y + ' Z'; }; PieBase.prototype.getDoughnutPath = function (center, start, end, radius, innerStart, innerEnd, innerRadius, clockWise) { return 'M ' + start.x + ' ' + start.y + ' A ' + radius + ' ' + radius + ' 0 ' + clockWise + ' 1 ' + end.x + ' ' + end.y + ' L ' + innerEnd.x + ' ' + innerEnd.y + ' A ' + innerRadius + ' ' + innerRadius + ' 0 ' + clockWise + ',0 ' + innerStart.x + ' ' + innerStart.y + ' Z'; }; PieBase.prototype.doAnimation = function (slice, series) { var _this = this; var startAngle = series.startAngle - 85; var value; var radius = Math.max(this.accumulation.availableSize.height, this.accumulation.availableSize.width) * 0.75; radius += radius * (0.414); var effect = helper_1.getAnimationFunction('Linear'); new ej2_base_1.Animation({}).animate(slice, { duration: series.animation.duration, delay: series.animation.delay, progress: function (args) { value = effect(args.timeStamp, startAngle, _this.totalAngle, args.duration); slice.setAttribute('d', _this.getPathArc(_this.center, startAngle, value, radius, 0)); }, end: function (args) { slice.setAttribute('d', _this.getPathArc(_this.center, 0, 359.99999, radius, 0)); _this.accumulation.trigger(constants_1.animationComplete, { series: series, accumulation: _this.accumulation }); var datalabelGroup = helper_1.getElement(_this.accumulation.element.id + '_datalabel_Series_' + series.index); datalabelGroup.style.visibility = _this.accumulation.isDestroyed ? 'hidden' : 'visible'; } }); }; return PieBase; }(accumulation_base_1.AccumulationBase)); exports.PieBase = PieBase; }); |