逐步完成前后端服务器
This commit is contained in:
215
frontend/node_modules/echarts/lib/chart/pie/PieSeries.js
generated
vendored
Normal file
215
frontend/node_modules/echarts/lib/chart/pie/PieSeries.js
generated
vendored
Normal file
@ -0,0 +1,215 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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 = /** @class */function (_super) {
|
||||
__extends(PieSeriesModel, _super);
|
||||
function PieSeriesModel() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/**
|
||||
* @overwrite
|
||||
*/
|
||||
PieSeriesModel.prototype.init = function (option) {
|
||||
_super.prototype.init.apply(this, arguments);
|
||||
// Enable legend selection for each data item
|
||||
// Use a function instead of direct access because data reference may changed
|
||||
this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
|
||||
this._defaultLabelLine(option);
|
||||
};
|
||||
/**
|
||||
* @overwrite
|
||||
*/
|
||||
PieSeriesModel.prototype.mergeOption = function () {
|
||||
_super.prototype.mergeOption.apply(this, arguments);
|
||||
};
|
||||
/**
|
||||
* @overwrite
|
||||
*/
|
||||
PieSeriesModel.prototype.getInitialData = function () {
|
||||
return createSeriesDataSimply(this, {
|
||||
coordDimensions: ['value'],
|
||||
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
|
||||
});
|
||||
};
|
||||
/**
|
||||
* @overwrite
|
||||
*/
|
||||
PieSeriesModel.prototype.getDataParams = function (dataIndex) {
|
||||
var data = this.getData();
|
||||
// update seats when data is changed
|
||||
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);
|
||||
// seats may be empty when sum is 0
|
||||
params.percent = seats[dataIndex] || 0;
|
||||
params.$vars.push('percent');
|
||||
return params;
|
||||
};
|
||||
PieSeriesModel.prototype._defaultLabelLine = function (option) {
|
||||
// Extend labelLine emphasis
|
||||
modelUtil.defaultEmphasis(option, 'labelLine', ['show']);
|
||||
var labelLineNormalOpt = option.labelLine;
|
||||
var labelLineEmphasisOpt = option.emphasis.labelLine;
|
||||
// Not show label line if `label.normal.show = false`
|
||||
labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
|
||||
labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
|
||||
};
|
||||
PieSeriesModel.type = 'series.pie';
|
||||
PieSeriesModel.defaultOption = {
|
||||
// zlevel: 0,
|
||||
z: 2,
|
||||
legendHoverLink: true,
|
||||
colorBy: 'data',
|
||||
// 默认全局居中
|
||||
center: ['50%', '50%'],
|
||||
radius: [0, '75%'],
|
||||
// 默认顺时针
|
||||
clockwise: true,
|
||||
startAngle: 90,
|
||||
endAngle: 'auto',
|
||||
padAngle: 0,
|
||||
// 最小角度改为0
|
||||
minAngle: 0,
|
||||
// If the angle of a sector less than `minShowLabelAngle`,
|
||||
// the label will not be displayed.
|
||||
minShowLabelAngle: 0,
|
||||
// 选中时扇区偏移量
|
||||
selectedOffset: 10,
|
||||
// 选择模式,默认关闭,可选single,multiple
|
||||
// selectedMode: false,
|
||||
// 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
|
||||
// roseType: null,
|
||||
percentPrecision: 2,
|
||||
// If still show when all data zero.
|
||||
stillShowZeroSum: true,
|
||||
// cursor: null,
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
width: null,
|
||||
height: null,
|
||||
label: {
|
||||
// color: 'inherit',
|
||||
// If rotate around circle
|
||||
rotate: 0,
|
||||
show: true,
|
||||
overflow: 'truncate',
|
||||
// 'outer', 'inside', 'center'
|
||||
position: 'outer',
|
||||
// 'none', 'labelLine', 'edge'. Works only when position is 'outer'
|
||||
alignTo: 'none',
|
||||
// Closest distance between label and chart edge.
|
||||
// Works only position is 'outer' and alignTo is 'edge'.
|
||||
edgeDistance: '25%',
|
||||
// Works only position is 'outer' and alignTo is not 'edge'.
|
||||
bleedMargin: 10,
|
||||
// Distance between text and label line.
|
||||
distanceToLabelLine: 5
|
||||
// formatter: 标签文本格式器,同 tooltip.formatter,不支持异步回调
|
||||
// 默认使用全局文本样式,详见 textStyle
|
||||
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
|
||||
},
|
||||
// Enabled when label.normal.position is 'outer'
|
||||
labelLine: {
|
||||
show: true,
|
||||
// 引导线两段中的第一段长度
|
||||
length: 15,
|
||||
// 引导线两段中的第二段长度
|
||||
length2: 15,
|
||||
smooth: false,
|
||||
minTurnAngle: 90,
|
||||
maxSurfaceAngle: 90,
|
||||
lineStyle: {
|
||||
// color: 各异,
|
||||
width: 1,
|
||||
type: 'solid'
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
borderWidth: 1,
|
||||
borderJoin: 'round'
|
||||
},
|
||||
showEmptyCircle: true,
|
||||
emptyCircleStyle: {
|
||||
color: 'lightgray',
|
||||
opacity: 1
|
||||
},
|
||||
labelLayout: {
|
||||
// Hide the overlapped label.
|
||||
hideOverlap: true
|
||||
},
|
||||
emphasis: {
|
||||
scale: true,
|
||||
scaleSize: 5
|
||||
},
|
||||
// If use strategy to avoid label overlapping
|
||||
avoidLabelOverlap: true,
|
||||
// Animation type. Valid values: expansion, scale
|
||||
animationType: 'expansion',
|
||||
animationDuration: 1000,
|
||||
// Animation type when update. Valid values: transition, expansion
|
||||
animationTypeUpdate: 'transition',
|
||||
animationEasingUpdate: 'cubicInOut',
|
||||
animationDurationUpdate: 500,
|
||||
animationEasing: 'cubicInOut'
|
||||
};
|
||||
return PieSeriesModel;
|
||||
}(SeriesModel);
|
||||
export default PieSeriesModel;
|
283
frontend/node_modules/echarts/lib/chart/pie/PieView.js
generated
vendored
Normal file
283
frontend/node_modules/echarts/lib/chart/pie/PieView.js
generated
vendored
Normal file
@ -0,0 +1,283 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import { extend, retrieve3 } from 'zrender/lib/core/util.js';
|
||||
import * as graphic from '../../util/graphic.js';
|
||||
import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states.js';
|
||||
import ChartView from '../../view/Chart.js';
|
||||
import labelLayout from './labelLayout.js';
|
||||
import { setLabelLineStyle, getLabelLineStatesModels } from '../../label/labelGuideHelper.js';
|
||||
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle.js';
|
||||
import { getSectorCornerRadius } from '../helper/sectorHelper.js';
|
||||
import { saveOldStyle } from '../../animation/basicTransition.js';
|
||||
import { getBasicPieLayout, getSeriesLayoutData } from './pieLayout.js';
|
||||
/**
|
||||
* Piece of pie including Sector, Label, LabelLine
|
||||
*/
|
||||
var PiePiece = /** @class */function (_super) {
|
||||
__extends(PiePiece, _super);
|
||||
function PiePiece(data, idx, startAngle) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.z2 = 2;
|
||||
var text = new graphic.Text();
|
||||
_this.setTextContent(text);
|
||||
_this.updateData(data, idx, startAngle, true);
|
||||
return _this;
|
||||
}
|
||||
PiePiece.prototype.updateData = function (data, idx, startAngle, firstCreate) {
|
||||
var sector = this;
|
||||
var seriesModel = data.hostModel;
|
||||
var itemModel = data.getItemModel(idx);
|
||||
var emphasisModel = itemModel.getModel('emphasis');
|
||||
var layout = data.getItemLayout(idx);
|
||||
// cornerRadius & innerCornerRadius doesn't exist in the item layout. Use `0` if null value is specified.
|
||||
// see `setItemLayout` in `pieLayout.ts`.
|
||||
var sectorShape = extend(getSectorCornerRadius(itemModel.getModel('itemStyle'), layout, true), layout);
|
||||
// Ignore NaN data.
|
||||
if (isNaN(sectorShape.startAngle)) {
|
||||
// Use NaN shape to avoid drawing shape.
|
||||
sector.setShape(sectorShape);
|
||||
return;
|
||||
}
|
||||
if (firstCreate) {
|
||||
sector.setShape(sectorShape);
|
||||
var animationType = seriesModel.getShallow('animationType');
|
||||
if (seriesModel.ecModel.ssr) {
|
||||
// Use scale animation in SSR mode(opacity?)
|
||||
// Because CSS SVG animation doesn't support very customized shape animation.
|
||||
graphic.initProps(sector, {
|
||||
scaleX: 0,
|
||||
scaleY: 0
|
||||
}, seriesModel, {
|
||||
dataIndex: idx,
|
||||
isFrom: true
|
||||
});
|
||||
sector.originX = sectorShape.cx;
|
||||
sector.originY = sectorShape.cy;
|
||||
} else if (animationType === 'scale') {
|
||||
sector.shape.r = layout.r0;
|
||||
graphic.initProps(sector, {
|
||||
shape: {
|
||||
r: layout.r
|
||||
}
|
||||
}, seriesModel, idx);
|
||||
}
|
||||
// Expansion
|
||||
else {
|
||||
if (startAngle != null) {
|
||||
sector.setShape({
|
||||
startAngle: startAngle,
|
||||
endAngle: startAngle
|
||||
});
|
||||
graphic.initProps(sector, {
|
||||
shape: {
|
||||
startAngle: layout.startAngle,
|
||||
endAngle: layout.endAngle
|
||||
}
|
||||
}, seriesModel, idx);
|
||||
} else {
|
||||
sector.shape.endAngle = layout.startAngle;
|
||||
graphic.updateProps(sector, {
|
||||
shape: {
|
||||
endAngle: layout.endAngle
|
||||
}
|
||||
}, seriesModel, idx);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
saveOldStyle(sector);
|
||||
// Transition animation from the old shape
|
||||
graphic.updateProps(sector, {
|
||||
shape: sectorShape
|
||||
}, seriesModel, idx);
|
||||
}
|
||||
sector.useStyle(data.getItemVisual(idx, 'style'));
|
||||
setStatesStylesFromModel(sector, itemModel);
|
||||
var midAngle = (layout.startAngle + layout.endAngle) / 2;
|
||||
var offset = seriesModel.get('selectedOffset');
|
||||
var dx = Math.cos(midAngle) * offset;
|
||||
var dy = Math.sin(midAngle) * offset;
|
||||
var cursorStyle = itemModel.getShallow('cursor');
|
||||
cursorStyle && sector.attr('cursor', cursorStyle);
|
||||
this._updateLabel(seriesModel, data, idx);
|
||||
sector.ensureState('emphasis').shape = extend({
|
||||
r: layout.r + (emphasisModel.get('scale') ? emphasisModel.get('scaleSize') || 0 : 0)
|
||||
}, getSectorCornerRadius(emphasisModel.getModel('itemStyle'), layout));
|
||||
extend(sector.ensureState('select'), {
|
||||
x: dx,
|
||||
y: dy,
|
||||
shape: getSectorCornerRadius(itemModel.getModel(['select', 'itemStyle']), layout)
|
||||
});
|
||||
extend(sector.ensureState('blur'), {
|
||||
shape: getSectorCornerRadius(itemModel.getModel(['blur', 'itemStyle']), layout)
|
||||
});
|
||||
var labelLine = sector.getTextGuideLine();
|
||||
var labelText = sector.getTextContent();
|
||||
labelLine && extend(labelLine.ensureState('select'), {
|
||||
x: dx,
|
||||
y: dy
|
||||
});
|
||||
// TODO: needs dx, dy in zrender?
|
||||
extend(labelText.ensureState('select'), {
|
||||
x: dx,
|
||||
y: dy
|
||||
});
|
||||
toggleHoverEmphasis(this, emphasisModel.get('focus'), emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
|
||||
};
|
||||
PiePiece.prototype._updateLabel = function (seriesModel, data, idx) {
|
||||
var sector = this;
|
||||
var itemModel = data.getItemModel(idx);
|
||||
var labelLineModel = itemModel.getModel('labelLine');
|
||||
var style = data.getItemVisual(idx, 'style');
|
||||
var visualColor = style && style.fill;
|
||||
var visualOpacity = style && style.opacity;
|
||||
setLabelStyle(sector, getLabelStatesModels(itemModel), {
|
||||
labelFetcher: data.hostModel,
|
||||
labelDataIndex: idx,
|
||||
inheritColor: visualColor,
|
||||
defaultOpacity: visualOpacity,
|
||||
defaultText: seriesModel.getFormattedLabel(idx, 'normal') || data.getName(idx)
|
||||
});
|
||||
var labelText = sector.getTextContent();
|
||||
// Set textConfig on sector.
|
||||
sector.setTextConfig({
|
||||
// reset position, rotation
|
||||
position: null,
|
||||
rotation: null
|
||||
});
|
||||
// Make sure update style on labelText after setLabelStyle.
|
||||
// Because setLabelStyle will replace a new style on it.
|
||||
labelText.attr({
|
||||
z2: 10
|
||||
});
|
||||
var labelPosition = seriesModel.get(['label', 'position']);
|
||||
if (labelPosition !== 'outside' && labelPosition !== 'outer') {
|
||||
sector.removeTextGuideLine();
|
||||
} else {
|
||||
var polyline = this.getTextGuideLine();
|
||||
if (!polyline) {
|
||||
polyline = new graphic.Polyline();
|
||||
this.setTextGuideLine(polyline);
|
||||
}
|
||||
// Default use item visual color
|
||||
setLabelLineStyle(this, getLabelLineStatesModels(itemModel), {
|
||||
stroke: visualColor,
|
||||
opacity: retrieve3(labelLineModel.get(['lineStyle', 'opacity']), visualOpacity, 1)
|
||||
});
|
||||
}
|
||||
};
|
||||
return PiePiece;
|
||||
}(graphic.Sector);
|
||||
// Pie view
|
||||
var PieView = /** @class */function (_super) {
|
||||
__extends(PieView, _super);
|
||||
function PieView() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.ignoreLabelLineUpdate = true;
|
||||
return _this;
|
||||
}
|
||||
PieView.prototype.render = function (seriesModel, ecModel, api, payload) {
|
||||
var data = seriesModel.getData();
|
||||
var oldData = this._data;
|
||||
var group = this.group;
|
||||
var startAngle;
|
||||
// First render
|
||||
if (!oldData && data.count() > 0) {
|
||||
var shape = data.getItemLayout(0);
|
||||
for (var s = 1; isNaN(shape && shape.startAngle) && s < data.count(); ++s) {
|
||||
shape = data.getItemLayout(s);
|
||||
}
|
||||
if (shape) {
|
||||
startAngle = shape.startAngle;
|
||||
}
|
||||
}
|
||||
// remove empty-circle if it exists
|
||||
if (this._emptyCircleSector) {
|
||||
group.remove(this._emptyCircleSector);
|
||||
}
|
||||
// when all data are filtered, show lightgray empty circle
|
||||
if (data.count() === 0 && seriesModel.get('showEmptyCircle')) {
|
||||
var layoutData = getSeriesLayoutData(seriesModel);
|
||||
var sector = new graphic.Sector({
|
||||
shape: extend(getBasicPieLayout(seriesModel, api), layoutData)
|
||||
});
|
||||
sector.useStyle(seriesModel.getModel('emptyCircleStyle').getItemStyle());
|
||||
this._emptyCircleSector = sector;
|
||||
group.add(sector);
|
||||
}
|
||||
data.diff(oldData).add(function (idx) {
|
||||
var piePiece = new PiePiece(data, idx, startAngle);
|
||||
data.setItemGraphicEl(idx, piePiece);
|
||||
group.add(piePiece);
|
||||
}).update(function (newIdx, oldIdx) {
|
||||
var piePiece = oldData.getItemGraphicEl(oldIdx);
|
||||
piePiece.updateData(data, newIdx, startAngle);
|
||||
piePiece.off('click');
|
||||
group.add(piePiece);
|
||||
data.setItemGraphicEl(newIdx, piePiece);
|
||||
}).remove(function (idx) {
|
||||
var piePiece = oldData.getItemGraphicEl(idx);
|
||||
graphic.removeElementWithFadeOut(piePiece, seriesModel, idx);
|
||||
}).execute();
|
||||
labelLayout(seriesModel);
|
||||
// Always use initial animation.
|
||||
if (seriesModel.get('animationTypeUpdate') !== 'expansion') {
|
||||
this._data = data;
|
||||
}
|
||||
};
|
||||
PieView.prototype.dispose = function () {};
|
||||
PieView.prototype.containPoint = function (point, seriesModel) {
|
||||
var data = seriesModel.getData();
|
||||
var itemLayout = data.getItemLayout(0);
|
||||
if (itemLayout) {
|
||||
var dx = point[0] - itemLayout.cx;
|
||||
var dy = point[1] - itemLayout.cy;
|
||||
var radius = Math.sqrt(dx * dx + dy * dy);
|
||||
return radius <= itemLayout.r && radius >= itemLayout.r0;
|
||||
}
|
||||
};
|
||||
PieView.type = 'pie';
|
||||
return PieView;
|
||||
}(ChartView);
|
||||
export default PieView;
|
58
frontend/node_modules/echarts/lib/chart/pie/install.js
generated
vendored
Normal file
58
frontend/node_modules/echarts/lib/chart/pie/install.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { createLegacyDataSelectAction } from '../../legacy/dataSelectAction.js';
|
||||
import pieLayout from '../pie/pieLayout.js';
|
||||
import dataFilter from '../../processor/dataFilter.js';
|
||||
import { curry } from 'zrender/lib/core/util.js';
|
||||
import PieView from './PieView.js';
|
||||
import PieSeriesModel from './PieSeries.js';
|
||||
import negativeDataFilter from '../../processor/negativeDataFilter.js';
|
||||
export function install(registers) {
|
||||
registers.registerChartView(PieView);
|
||||
registers.registerSeriesModel(PieSeriesModel);
|
||||
createLegacyDataSelectAction('pie', registers.registerAction);
|
||||
registers.registerLayout(curry(pieLayout, 'pie'));
|
||||
registers.registerProcessor(dataFilter('pie'));
|
||||
registers.registerProcessor(negativeDataFilter('pie'));
|
||||
}
|
474
frontend/node_modules/echarts/lib/chart/pie/labelLayout.js
generated
vendored
Normal file
474
frontend/node_modules/echarts/lib/chart/pie/labelLayout.js
generated
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// FIXME emphasis label position is not same with normal label position
|
||||
import { parsePercent } from '../../util/number.js';
|
||||
import { Point } from '../../util/graphic.js';
|
||||
import { each, isNumber } from 'zrender/lib/core/util.js';
|
||||
import { limitTurnAngle, limitSurfaceAngle } from '../../label/labelGuideHelper.js';
|
||||
import { shiftLayoutOnY } from '../../label/labelLayoutHelper.js';
|
||||
var RADIAN = Math.PI / 180;
|
||||
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
|
||||
if (list.length < 2) {
|
||||
return;
|
||||
}
|
||||
;
|
||||
function recalculateXOnSemiToAlignOnEllipseCurve(semi) {
|
||||
var rB = semi.rB;
|
||||
var rB2 = rB * rB;
|
||||
for (var i = 0; i < semi.list.length; i++) {
|
||||
var item = semi.list[i];
|
||||
var dy = Math.abs(item.label.y - cy);
|
||||
// horizontal r is always same with original r because x is not changed.
|
||||
var rA = r + item.len;
|
||||
var rA2 = rA * rA;
|
||||
// Use ellipse implicit function to calculate x
|
||||
var dx = Math.sqrt(Math.abs((1 - dy * dy / rB2) * rA2));
|
||||
var newX = cx + (dx + item.len2) * dir;
|
||||
var deltaX = newX - item.label.x;
|
||||
var newTargetWidth = item.targetTextWidth - deltaX * dir;
|
||||
// text x is changed, so need to recalculate width.
|
||||
constrainTextWidth(item, newTargetWidth, true);
|
||||
item.label.x = newX;
|
||||
}
|
||||
}
|
||||
// Adjust X based on the shifted y. Make tight labels aligned on an ellipse curve.
|
||||
function recalculateX(items) {
|
||||
// Extremes of
|
||||
var topSemi = {
|
||||
list: [],
|
||||
maxY: 0
|
||||
};
|
||||
var bottomSemi = {
|
||||
list: [],
|
||||
maxY: 0
|
||||
};
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].labelAlignTo !== 'none') {
|
||||
continue;
|
||||
}
|
||||
var item = items[i];
|
||||
var semi = item.label.y > cy ? bottomSemi : topSemi;
|
||||
var dy = Math.abs(item.label.y - cy);
|
||||
if (dy >= semi.maxY) {
|
||||
var dx = item.label.x - cx - item.len2 * dir;
|
||||
// horizontal r is always same with original r because x is not changed.
|
||||
var rA = r + item.len;
|
||||
// Canculate rB based on the topest / bottemest label.
|
||||
var rB = Math.abs(dx) < rA ? Math.sqrt(dy * dy / (1 - dx * dx / rA / rA)) : rA;
|
||||
semi.rB = rB;
|
||||
semi.maxY = dy;
|
||||
}
|
||||
semi.list.push(item);
|
||||
}
|
||||
recalculateXOnSemiToAlignOnEllipseCurve(topSemi);
|
||||
recalculateXOnSemiToAlignOnEllipseCurve(bottomSemi);
|
||||
}
|
||||
var len = list.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (list[i].position === 'outer' && list[i].labelAlignTo === 'labelLine') {
|
||||
var dx = list[i].label.x - farthestX;
|
||||
list[i].linePoints[1][0] += dx;
|
||||
list[i].label.x = farthestX;
|
||||
}
|
||||
}
|
||||
if (shiftLayoutOnY(list, viewTop, viewTop + viewHeight)) {
|
||||
recalculateX(list);
|
||||
}
|
||||
}
|
||||
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
||||
var leftList = [];
|
||||
var rightList = [];
|
||||
var leftmostX = Number.MAX_VALUE;
|
||||
var rightmostX = -Number.MAX_VALUE;
|
||||
for (var i = 0; i < labelLayoutList.length; i++) {
|
||||
var label = labelLayoutList[i].label;
|
||||
if (isPositionCenter(labelLayoutList[i])) {
|
||||
continue;
|
||||
}
|
||||
if (label.x < cx) {
|
||||
leftmostX = Math.min(leftmostX, label.x);
|
||||
leftList.push(labelLayoutList[i]);
|
||||
} else {
|
||||
rightmostX = Math.max(rightmostX, label.x);
|
||||
rightList.push(labelLayoutList[i]);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < labelLayoutList.length; i++) {
|
||||
var layout = labelLayoutList[i];
|
||||
if (!isPositionCenter(layout) && layout.linePoints) {
|
||||
if (layout.labelStyleWidth != null) {
|
||||
continue;
|
||||
}
|
||||
var label = layout.label;
|
||||
var linePoints = layout.linePoints;
|
||||
var targetTextWidth = void 0;
|
||||
if (layout.labelAlignTo === 'edge') {
|
||||
if (label.x < cx) {
|
||||
targetTextWidth = linePoints[2][0] - layout.labelDistance - viewLeft - layout.edgeDistance;
|
||||
} else {
|
||||
targetTextWidth = viewLeft + viewWidth - layout.edgeDistance - linePoints[2][0] - layout.labelDistance;
|
||||
}
|
||||
} else if (layout.labelAlignTo === 'labelLine') {
|
||||
if (label.x < cx) {
|
||||
targetTextWidth = leftmostX - viewLeft - layout.bleedMargin;
|
||||
} else {
|
||||
targetTextWidth = viewLeft + viewWidth - rightmostX - layout.bleedMargin;
|
||||
}
|
||||
} else {
|
||||
if (label.x < cx) {
|
||||
targetTextWidth = label.x - viewLeft - layout.bleedMargin;
|
||||
} else {
|
||||
targetTextWidth = viewLeft + viewWidth - label.x - layout.bleedMargin;
|
||||
}
|
||||
}
|
||||
layout.targetTextWidth = targetTextWidth;
|
||||
constrainTextWidth(layout, targetTextWidth);
|
||||
}
|
||||
}
|
||||
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight, viewLeft, viewTop, rightmostX);
|
||||
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight, viewLeft, viewTop, leftmostX);
|
||||
for (var i = 0; i < labelLayoutList.length; i++) {
|
||||
var layout = labelLayoutList[i];
|
||||
if (!isPositionCenter(layout) && layout.linePoints) {
|
||||
var label = layout.label;
|
||||
var linePoints = layout.linePoints;
|
||||
var isAlignToEdge = layout.labelAlignTo === 'edge';
|
||||
var padding = label.style.padding;
|
||||
var paddingH = padding ? padding[1] + padding[3] : 0;
|
||||
// textRect.width already contains paddingH if bgColor is set
|
||||
var extraPaddingH = label.style.backgroundColor ? 0 : paddingH;
|
||||
var realTextWidth = layout.rect.width + extraPaddingH;
|
||||
var dist = linePoints[1][0] - linePoints[2][0];
|
||||
if (isAlignToEdge) {
|
||||
if (label.x < cx) {
|
||||
linePoints[2][0] = viewLeft + layout.edgeDistance + realTextWidth + layout.labelDistance;
|
||||
} else {
|
||||
linePoints[2][0] = viewLeft + viewWidth - layout.edgeDistance - realTextWidth - layout.labelDistance;
|
||||
}
|
||||
} else {
|
||||
if (label.x < cx) {
|
||||
linePoints[2][0] = label.x + layout.labelDistance;
|
||||
} else {
|
||||
linePoints[2][0] = label.x - layout.labelDistance;
|
||||
}
|
||||
linePoints[1][0] = linePoints[2][0] + dist;
|
||||
}
|
||||
linePoints[1][1] = linePoints[2][1] = label.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set max width of each label, and then wrap each label to the max width.
|
||||
*
|
||||
* @param layout label layout
|
||||
* @param availableWidth max width for the label to display
|
||||
* @param forceRecalculate recaculate the text layout even if the current width
|
||||
* is smaller than `availableWidth`. This is useful when the text was previously
|
||||
* wrapped by calling `constrainTextWidth` but now `availableWidth` changed, in
|
||||
* which case, previous wrapping should be redo.
|
||||
*/
|
||||
function constrainTextWidth(layout, availableWidth, forceRecalculate) {
|
||||
if (forceRecalculate === void 0) {
|
||||
forceRecalculate = false;
|
||||
}
|
||||
if (layout.labelStyleWidth != null) {
|
||||
// User-defined style.width has the highest priority.
|
||||
return;
|
||||
}
|
||||
var label = layout.label;
|
||||
var style = label.style;
|
||||
var textRect = layout.rect;
|
||||
var bgColor = style.backgroundColor;
|
||||
var padding = style.padding;
|
||||
var paddingH = padding ? padding[1] + padding[3] : 0;
|
||||
var overflow = style.overflow;
|
||||
// textRect.width already contains paddingH if bgColor is set
|
||||
var oldOuterWidth = textRect.width + (bgColor ? 0 : paddingH);
|
||||
if (availableWidth < oldOuterWidth || forceRecalculate) {
|
||||
var oldHeight = textRect.height;
|
||||
if (overflow && overflow.match('break')) {
|
||||
// Temporarily set background to be null to calculate
|
||||
// the bounding box without background.
|
||||
label.setStyle('backgroundColor', null);
|
||||
// Set constraining width
|
||||
label.setStyle('width', availableWidth - paddingH);
|
||||
// This is the real bounding box of the text without padding.
|
||||
var innerRect = label.getBoundingRect();
|
||||
label.setStyle('width', Math.ceil(innerRect.width));
|
||||
label.setStyle('backgroundColor', bgColor);
|
||||
} else {
|
||||
var availableInnerWidth = availableWidth - paddingH;
|
||||
var newWidth = availableWidth < oldOuterWidth
|
||||
// Current text is too wide, use `availableWidth` as max width.
|
||||
? availableInnerWidth :
|
||||
// Current available width is enough, but the text may have
|
||||
// already been wrapped with a smaller available width.
|
||||
forceRecalculate ? availableInnerWidth > layout.unconstrainedWidth
|
||||
// Current available is larger than text width,
|
||||
// so don't constrain width (otherwise it may have
|
||||
// empty space in the background).
|
||||
? null
|
||||
// Current available is smaller than text width, so
|
||||
// use the current available width as constraining
|
||||
// width.
|
||||
: availableInnerWidth
|
||||
// Current available width is enough, so no need to
|
||||
// constrain.
|
||||
: null;
|
||||
label.setStyle('width', newWidth);
|
||||
}
|
||||
var newRect = label.getBoundingRect();
|
||||
textRect.width = newRect.width;
|
||||
var margin = (label.style.margin || 0) + 2.1;
|
||||
textRect.height = newRect.height + margin;
|
||||
textRect.y -= (textRect.height - oldHeight) / 2;
|
||||
}
|
||||
}
|
||||
function isPositionCenter(sectorShape) {
|
||||
// Not change x for center label
|
||||
return sectorShape.position === 'center';
|
||||
}
|
||||
export default function pieLabelLayout(seriesModel) {
|
||||
var data = seriesModel.getData();
|
||||
var labelLayoutList = [];
|
||||
var cx;
|
||||
var cy;
|
||||
var hasLabelRotate = false;
|
||||
var minShowLabelRadian = (seriesModel.get('minShowLabelAngle') || 0) * RADIAN;
|
||||
var viewRect = data.getLayout('viewRect');
|
||||
var r = data.getLayout('r');
|
||||
var viewWidth = viewRect.width;
|
||||
var viewLeft = viewRect.x;
|
||||
var viewTop = viewRect.y;
|
||||
var viewHeight = viewRect.height;
|
||||
function setNotShow(el) {
|
||||
el.ignore = true;
|
||||
}
|
||||
function isLabelShown(label) {
|
||||
if (!label.ignore) {
|
||||
return true;
|
||||
}
|
||||
for (var key in label.states) {
|
||||
if (label.states[key].ignore === false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
data.each(function (idx) {
|
||||
var sector = data.getItemGraphicEl(idx);
|
||||
var sectorShape = sector.shape;
|
||||
var label = sector.getTextContent();
|
||||
var labelLine = sector.getTextGuideLine();
|
||||
var itemModel = data.getItemModel(idx);
|
||||
var labelModel = itemModel.getModel('label');
|
||||
// Use position in normal or emphasis
|
||||
var labelPosition = labelModel.get('position') || itemModel.get(['emphasis', 'label', 'position']);
|
||||
var labelDistance = labelModel.get('distanceToLabelLine');
|
||||
var labelAlignTo = labelModel.get('alignTo');
|
||||
var edgeDistance = parsePercent(labelModel.get('edgeDistance'), viewWidth);
|
||||
var bleedMargin = labelModel.get('bleedMargin');
|
||||
var labelLineModel = itemModel.getModel('labelLine');
|
||||
var labelLineLen = labelLineModel.get('length');
|
||||
labelLineLen = parsePercent(labelLineLen, viewWidth);
|
||||
var labelLineLen2 = labelLineModel.get('length2');
|
||||
labelLineLen2 = parsePercent(labelLineLen2, viewWidth);
|
||||
if (Math.abs(sectorShape.endAngle - sectorShape.startAngle) < minShowLabelRadian) {
|
||||
each(label.states, setNotShow);
|
||||
label.ignore = true;
|
||||
if (labelLine) {
|
||||
each(labelLine.states, setNotShow);
|
||||
labelLine.ignore = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!isLabelShown(label)) {
|
||||
return;
|
||||
}
|
||||
var midAngle = (sectorShape.startAngle + sectorShape.endAngle) / 2;
|
||||
var nx = Math.cos(midAngle);
|
||||
var ny = Math.sin(midAngle);
|
||||
var textX;
|
||||
var textY;
|
||||
var linePoints;
|
||||
var textAlign;
|
||||
cx = sectorShape.cx;
|
||||
cy = sectorShape.cy;
|
||||
var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
|
||||
if (labelPosition === 'center') {
|
||||
textX = sectorShape.cx;
|
||||
textY = sectorShape.cy;
|
||||
textAlign = 'center';
|
||||
} else {
|
||||
var x1 = (isLabelInside ? (sectorShape.r + sectorShape.r0) / 2 * nx : sectorShape.r * nx) + cx;
|
||||
var y1 = (isLabelInside ? (sectorShape.r + sectorShape.r0) / 2 * ny : sectorShape.r * ny) + cy;
|
||||
textX = x1 + nx * 3;
|
||||
textY = y1 + ny * 3;
|
||||
if (!isLabelInside) {
|
||||
// For roseType
|
||||
var x2 = x1 + nx * (labelLineLen + r - sectorShape.r);
|
||||
var y2 = y1 + ny * (labelLineLen + r - sectorShape.r);
|
||||
var x3 = x2 + (nx < 0 ? -1 : 1) * labelLineLen2;
|
||||
var y3 = y2;
|
||||
if (labelAlignTo === 'edge') {
|
||||
// Adjust textX because text align of edge is opposite
|
||||
textX = nx < 0 ? viewLeft + edgeDistance : viewLeft + viewWidth - edgeDistance;
|
||||
} else {
|
||||
textX = x3 + (nx < 0 ? -labelDistance : labelDistance);
|
||||
}
|
||||
textY = y3;
|
||||
linePoints = [[x1, y1], [x2, y2], [x3, y3]];
|
||||
}
|
||||
textAlign = isLabelInside ? 'center' : labelAlignTo === 'edge' ? nx > 0 ? 'right' : 'left' : nx > 0 ? 'left' : 'right';
|
||||
}
|
||||
var PI = Math.PI;
|
||||
var labelRotate = 0;
|
||||
var rotate = labelModel.get('rotate');
|
||||
if (isNumber(rotate)) {
|
||||
labelRotate = rotate * (PI / 180);
|
||||
} else if (labelPosition === 'center') {
|
||||
labelRotate = 0;
|
||||
} else if (rotate === 'radial' || rotate === true) {
|
||||
var radialAngle = nx < 0 ? -midAngle + PI : -midAngle;
|
||||
labelRotate = radialAngle;
|
||||
} else if (rotate === 'tangential' && labelPosition !== 'outside' && labelPosition !== 'outer') {
|
||||
var rad = Math.atan2(nx, ny);
|
||||
if (rad < 0) {
|
||||
rad = PI * 2 + rad;
|
||||
}
|
||||
var isDown = ny > 0;
|
||||
if (isDown) {
|
||||
rad = PI + rad;
|
||||
}
|
||||
labelRotate = rad - PI;
|
||||
}
|
||||
hasLabelRotate = !!labelRotate;
|
||||
label.x = textX;
|
||||
label.y = textY;
|
||||
label.rotation = labelRotate;
|
||||
label.setStyle({
|
||||
verticalAlign: 'middle'
|
||||
});
|
||||
// Not sectorShape the inside label
|
||||
if (!isLabelInside) {
|
||||
var textRect = label.getBoundingRect().clone();
|
||||
textRect.applyTransform(label.getComputedTransform());
|
||||
// Text has a default 1px stroke. Exclude this.
|
||||
var margin = (label.style.margin || 0) + 2.1;
|
||||
textRect.y -= margin / 2;
|
||||
textRect.height += margin;
|
||||
labelLayoutList.push({
|
||||
label: label,
|
||||
labelLine: labelLine,
|
||||
position: labelPosition,
|
||||
len: labelLineLen,
|
||||
len2: labelLineLen2,
|
||||
minTurnAngle: labelLineModel.get('minTurnAngle'),
|
||||
maxSurfaceAngle: labelLineModel.get('maxSurfaceAngle'),
|
||||
surfaceNormal: new Point(nx, ny),
|
||||
linePoints: linePoints,
|
||||
textAlign: textAlign,
|
||||
labelDistance: labelDistance,
|
||||
labelAlignTo: labelAlignTo,
|
||||
edgeDistance: edgeDistance,
|
||||
bleedMargin: bleedMargin,
|
||||
rect: textRect,
|
||||
unconstrainedWidth: textRect.width,
|
||||
labelStyleWidth: label.style.width
|
||||
});
|
||||
} else {
|
||||
label.setStyle({
|
||||
align: textAlign
|
||||
});
|
||||
var selectState = label.states.select;
|
||||
if (selectState) {
|
||||
selectState.x += label.x;
|
||||
selectState.y += label.y;
|
||||
}
|
||||
}
|
||||
sector.setTextConfig({
|
||||
inside: isLabelInside
|
||||
});
|
||||
});
|
||||
if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
|
||||
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
|
||||
}
|
||||
for (var i = 0; i < labelLayoutList.length; i++) {
|
||||
var layout = labelLayoutList[i];
|
||||
var label = layout.label;
|
||||
var labelLine = layout.labelLine;
|
||||
var notShowLabel = isNaN(label.x) || isNaN(label.y);
|
||||
if (label) {
|
||||
label.setStyle({
|
||||
align: layout.textAlign
|
||||
});
|
||||
if (notShowLabel) {
|
||||
each(label.states, setNotShow);
|
||||
label.ignore = true;
|
||||
}
|
||||
var selectState = label.states.select;
|
||||
if (selectState) {
|
||||
selectState.x += label.x;
|
||||
selectState.y += label.y;
|
||||
}
|
||||
}
|
||||
if (labelLine) {
|
||||
var linePoints = layout.linePoints;
|
||||
if (notShowLabel || !linePoints) {
|
||||
each(labelLine.states, setNotShow);
|
||||
labelLine.ignore = true;
|
||||
} else {
|
||||
limitTurnAngle(linePoints, layout.minTurnAngle);
|
||||
limitSurfaceAngle(linePoints, layout.surfaceNormal, layout.maxSurfaceAngle);
|
||||
labelLine.setShape({
|
||||
points: linePoints
|
||||
});
|
||||
// Set the anchor to the midpoint of sector
|
||||
label.__hostTarget.textGuideLineConfig = {
|
||||
anchor: new Point(linePoints[0][0], linePoints[0][1])
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
238
frontend/node_modules/echarts/lib/chart/pie/pieLayout.js
generated
vendored
Normal file
238
frontend/node_modules/echarts/lib/chart/pie/pieLayout.js
generated
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { parsePercent, linearMap } from '../../util/number.js';
|
||||
import * as layout from '../../util/layout.js';
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import { normalizeArcAngles } from 'zrender/lib/core/PathProxy.js';
|
||||
import { makeInner } from '../../util/model.js';
|
||||
var PI2 = Math.PI * 2;
|
||||
var RADIAN = Math.PI / 180;
|
||||
function getViewRect(seriesModel, api) {
|
||||
return layout.getLayoutRect(seriesModel.getBoxLayoutParams(), {
|
||||
width: api.getWidth(),
|
||||
height: api.getHeight()
|
||||
});
|
||||
}
|
||||
export function getBasicPieLayout(seriesModel, api) {
|
||||
var viewRect = getViewRect(seriesModel, api);
|
||||
// center can be string or number when coordinateSystem is specified
|
||||
var center = seriesModel.get('center');
|
||||
var radius = seriesModel.get('radius');
|
||||
if (!zrUtil.isArray(radius)) {
|
||||
radius = [0, radius];
|
||||
}
|
||||
var width = parsePercent(viewRect.width, api.getWidth());
|
||||
var height = parsePercent(viewRect.height, api.getHeight());
|
||||
var size = Math.min(width, height);
|
||||
var r0 = parsePercent(radius[0], size / 2);
|
||||
var r = parsePercent(radius[1], size / 2);
|
||||
var cx;
|
||||
var cy;
|
||||
var coordSys = seriesModel.coordinateSystem;
|
||||
if (coordSys) {
|
||||
// percentage is not allowed when coordinate system is specified
|
||||
var point = coordSys.dataToPoint(center);
|
||||
cx = point[0] || 0;
|
||||
cy = point[1] || 0;
|
||||
} else {
|
||||
if (!zrUtil.isArray(center)) {
|
||||
center = [center, center];
|
||||
}
|
||||
cx = parsePercent(center[0], width) + viewRect.x;
|
||||
cy = parsePercent(center[1], height) + viewRect.y;
|
||||
}
|
||||
return {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r0: r0,
|
||||
r: r
|
||||
};
|
||||
}
|
||||
export default function pieLayout(seriesType, ecModel, api) {
|
||||
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
|
||||
var data = seriesModel.getData();
|
||||
var valueDim = data.mapDimension('value');
|
||||
var viewRect = getViewRect(seriesModel, api);
|
||||
var _a = getBasicPieLayout(seriesModel, api),
|
||||
cx = _a.cx,
|
||||
cy = _a.cy,
|
||||
r = _a.r,
|
||||
r0 = _a.r0;
|
||||
var startAngle = -seriesModel.get('startAngle') * RADIAN;
|
||||
var endAngle = seriesModel.get('endAngle');
|
||||
var padAngle = seriesModel.get('padAngle') * RADIAN;
|
||||
endAngle = endAngle === 'auto' ? startAngle - PI2 : -endAngle * RADIAN;
|
||||
var minAngle = seriesModel.get('minAngle') * RADIAN;
|
||||
var minAndPadAngle = minAngle + padAngle;
|
||||
var validDataCount = 0;
|
||||
data.each(valueDim, function (value) {
|
||||
!isNaN(value) && validDataCount++;
|
||||
});
|
||||
var sum = data.getSum(valueDim);
|
||||
// Sum may be 0
|
||||
var unitRadian = Math.PI / (sum || validDataCount) * 2;
|
||||
var clockwise = seriesModel.get('clockwise');
|
||||
var roseType = seriesModel.get('roseType');
|
||||
var stillShowZeroSum = seriesModel.get('stillShowZeroSum');
|
||||
// [0...max]
|
||||
var extent = data.getDataExtent(valueDim);
|
||||
extent[0] = 0;
|
||||
var dir = clockwise ? 1 : -1;
|
||||
var angles = [startAngle, endAngle];
|
||||
var halfPadAngle = dir * padAngle / 2;
|
||||
normalizeArcAngles(angles, !clockwise);
|
||||
startAngle = angles[0], endAngle = angles[1];
|
||||
var layoutData = getSeriesLayoutData(seriesModel);
|
||||
layoutData.startAngle = startAngle;
|
||||
layoutData.endAngle = endAngle;
|
||||
layoutData.clockwise = clockwise;
|
||||
var angleRange = Math.abs(endAngle - startAngle);
|
||||
// In the case some sector angle is smaller than minAngle
|
||||
var restAngle = angleRange;
|
||||
var valueSumLargerThanMinAngle = 0;
|
||||
var currentAngle = startAngle;
|
||||
data.setLayout({
|
||||
viewRect: viewRect,
|
||||
r: r
|
||||
});
|
||||
data.each(valueDim, function (value, idx) {
|
||||
var angle;
|
||||
if (isNaN(value)) {
|
||||
data.setItemLayout(idx, {
|
||||
angle: NaN,
|
||||
startAngle: NaN,
|
||||
endAngle: NaN,
|
||||
clockwise: clockwise,
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r0: r0,
|
||||
r: roseType ? NaN : r
|
||||
});
|
||||
return;
|
||||
}
|
||||
// FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
|
||||
if (roseType !== 'area') {
|
||||
angle = sum === 0 && stillShowZeroSum ? unitRadian : value * unitRadian;
|
||||
} else {
|
||||
angle = angleRange / validDataCount;
|
||||
}
|
||||
if (angle < minAndPadAngle) {
|
||||
angle = minAndPadAngle;
|
||||
restAngle -= minAndPadAngle;
|
||||
} else {
|
||||
valueSumLargerThanMinAngle += value;
|
||||
}
|
||||
var endAngle = currentAngle + dir * angle;
|
||||
// calculate display angle
|
||||
var actualStartAngle = 0;
|
||||
var actualEndAngle = 0;
|
||||
if (padAngle > angle) {
|
||||
actualStartAngle = currentAngle + dir * angle / 2;
|
||||
actualEndAngle = actualStartAngle;
|
||||
} else {
|
||||
actualStartAngle = currentAngle + halfPadAngle;
|
||||
actualEndAngle = endAngle - halfPadAngle;
|
||||
}
|
||||
data.setItemLayout(idx, {
|
||||
angle: angle,
|
||||
startAngle: actualStartAngle,
|
||||
endAngle: actualEndAngle,
|
||||
clockwise: clockwise,
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r0: r0,
|
||||
r: roseType ? linearMap(value, extent, [r0, r]) : r
|
||||
});
|
||||
currentAngle = endAngle;
|
||||
});
|
||||
// Some sector is constrained by minAngle and padAngle
|
||||
// Rest sectors needs recalculate angle
|
||||
if (restAngle < PI2 && validDataCount) {
|
||||
// Average the angle if rest angle is not enough after all angles is
|
||||
// Constrained by minAngle and padAngle
|
||||
if (restAngle <= 1e-3) {
|
||||
var angle_1 = angleRange / validDataCount;
|
||||
data.each(valueDim, function (value, idx) {
|
||||
if (!isNaN(value)) {
|
||||
var layout_1 = data.getItemLayout(idx);
|
||||
layout_1.angle = angle_1;
|
||||
var actualStartAngle = 0;
|
||||
var actualEndAngle = 0;
|
||||
if (angle_1 < padAngle) {
|
||||
actualStartAngle = startAngle + dir * (idx + 1 / 2) * angle_1;
|
||||
actualEndAngle = actualStartAngle;
|
||||
} else {
|
||||
actualStartAngle = startAngle + dir * idx * angle_1 + halfPadAngle;
|
||||
actualEndAngle = startAngle + dir * (idx + 1) * angle_1 - halfPadAngle;
|
||||
}
|
||||
layout_1.startAngle = actualStartAngle;
|
||||
layout_1.endAngle = actualEndAngle;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
unitRadian = restAngle / valueSumLargerThanMinAngle;
|
||||
currentAngle = startAngle;
|
||||
data.each(valueDim, function (value, idx) {
|
||||
if (!isNaN(value)) {
|
||||
var layout_2 = data.getItemLayout(idx);
|
||||
var angle = layout_2.angle === minAndPadAngle ? minAndPadAngle : value * unitRadian;
|
||||
var actualStartAngle = 0;
|
||||
var actualEndAngle = 0;
|
||||
if (angle < padAngle) {
|
||||
actualStartAngle = currentAngle + dir * angle / 2;
|
||||
actualEndAngle = actualStartAngle;
|
||||
} else {
|
||||
actualStartAngle = currentAngle + halfPadAngle;
|
||||
actualEndAngle = currentAngle + dir * angle - halfPadAngle;
|
||||
}
|
||||
layout_2.startAngle = actualStartAngle;
|
||||
layout_2.endAngle = actualEndAngle;
|
||||
currentAngle += dir * angle;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
export var getSeriesLayoutData = makeInner();
|
Reference in New Issue
Block a user