123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- import { __extends } from "tslib";
- import createSeriesDataSimply from '../helper/createSeriesDataSimply.js';
- import * as zrUtil from 'zrender/lib/core/util.js';
- import * as modelUtil from '../../util/model.js';
- import { getPercentSeats } from '../../util/number.js';
- import { makeSeriesEncodeForNameBased } from '../../data/helper/sourceHelper.js';
- import LegendVisualProvider from '../../visual/LegendVisualProvider.js';
- import SeriesModel from '../../model/Series.js';
- var innerData = modelUtil.makeInner();
- var PieSeriesModel = function (_super) {
- __extends(PieSeriesModel, _super);
- function PieSeriesModel() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
-
- PieSeriesModel.prototype.init = function (option) {
- _super.prototype.init.apply(this, arguments);
-
-
- this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
- this._defaultLabelLine(option);
- };
-
- PieSeriesModel.prototype.mergeOption = function () {
- _super.prototype.mergeOption.apply(this, arguments);
- };
-
- PieSeriesModel.prototype.getInitialData = function () {
- return createSeriesDataSimply(this, {
- coordDimensions: ['value'],
- encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
- });
- };
-
- PieSeriesModel.prototype.getDataParams = function (dataIndex) {
- var data = this.getData();
-
- var dataInner = innerData(data);
- var seats = dataInner.seats;
- if (!seats) {
- var valueList_1 = [];
- data.each(data.mapDimension('value'), function (value) {
- valueList_1.push(value);
- });
- seats = dataInner.seats = getPercentSeats(valueList_1, data.hostModel.get('percentPrecision'));
- }
- var params = _super.prototype.getDataParams.call(this, dataIndex);
-
- params.percent = seats[dataIndex] || 0;
- params.$vars.push('percent');
- return params;
- };
- PieSeriesModel.prototype._defaultLabelLine = function (option) {
-
- modelUtil.defaultEmphasis(option, 'labelLine', ['show']);
- var labelLineNormalOpt = option.labelLine;
- var labelLineEmphasisOpt = option.emphasis.labelLine;
-
- labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
- labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
- };
- PieSeriesModel.type = 'series.pie';
- PieSeriesModel.defaultOption = {
-
- z: 2,
- legendHoverLink: true,
- colorBy: 'data',
-
- center: ['50%', '50%'],
- radius: [0, '75%'],
-
- clockwise: true,
- startAngle: 90,
- endAngle: 'auto',
- padAngle: 0,
-
- minAngle: 0,
-
-
- minShowLabelAngle: 0,
-
- selectedOffset: 10,
-
-
-
-
- percentPrecision: 2,
-
- stillShowZeroSum: true,
-
- left: 0,
- top: 0,
- right: 0,
- bottom: 0,
- width: null,
- height: null,
- label: {
-
-
- rotate: 0,
- show: true,
- overflow: 'truncate',
-
- position: 'outer',
-
- alignTo: 'none',
-
-
- edgeDistance: '25%',
-
- bleedMargin: 10,
-
- distanceToLabelLine: 5
-
-
-
- },
-
- labelLine: {
- show: true,
-
- length: 15,
-
- length2: 15,
- smooth: false,
- minTurnAngle: 90,
- maxSurfaceAngle: 90,
- lineStyle: {
-
- width: 1,
- type: 'solid'
- }
- },
- itemStyle: {
- borderWidth: 1,
- borderJoin: 'round'
- },
- showEmptyCircle: true,
- emptyCircleStyle: {
- color: 'lightgray',
- opacity: 1
- },
- labelLayout: {
-
- hideOverlap: true
- },
- emphasis: {
- scale: true,
- scaleSize: 5
- },
-
- avoidLabelOverlap: true,
-
- animationType: 'expansion',
- animationDuration: 1000,
-
- animationTypeUpdate: 'transition',
- animationEasingUpdate: 'cubicInOut',
- animationDurationUpdate: 500,
- animationEasing: 'cubicInOut'
- };
- return PieSeriesModel;
- }(SeriesModel);
- export default PieSeriesModel;
|