Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private getAnimateCfg(animateType: string) {
const animate = this.animate;
const { geometryType, coordinate } = this.shapeFactory;
const defaultCfg = getDefaultAnimateCfg(geometryType, coordinate, animateType);
// 1. animate === false, 用户关闭动画
// 2. 动画默认开启,用户没有对动画进行配置同时有没有内置的默认动画
// 3. 用户关闭对应的动画 animate: { enter: false }
if (
!animate ||
(animate === true && isEmpty(defaultCfg)) ||
animate[animateType] === false ||
animate[animateType] === null
) {
return null;
}
return {
...defaultCfg,
...animate[animateType],
};
}
public getDefaultValue(attrName: string) {
let value: any;
const attr = this.getAttribute(attrName);
if (attr && _.isEmpty(attr.scales)) {
// 获取映射至常量的值
value = attr.values[0];
}
return value;
}
private filterLabels(shape, element: Element, visible: boolean) {
if (shape.get('gLabel')) {
// shape 中缓存了 gLabel Shape
shape.get('gLabel').set('visible', visible);
} else {
/* 从 label 中获取 shape 对应的 label item */
const labelOptions = element.get('labelOptions');
if (!_.isEmpty(_.get(labelOptions, 'fields'))) {
const { field: xField } = element.getXScale();
const { field: yField } = element.getYScale();
const shapeData = shape.get('origin')._origin;
const labels = element.get('labels') as Label[];
_.each(labels, (label) => {
const labelData = label.get('origin') || [];
if (labelData[xField] === shapeData[xField] && labelData[yField] === shapeData[yField]) {
label.set('visible', visible);
shape.set('gLabel', label);
}
});
}
}
}
public createAxis(xScale: Scale, yScales: Scale[], viewId) {
const coord = this.coord;
const coordType = coord.type;
// theta坐标系默认不绘制坐标轴
if (coordType !== 'theta' && !(coordType === 'polar' && coord.isTransposed)) {
let xAxis;
if (xScale && !this._isHide(xScale.field)) {
xAxis = this._drawAxis(coord, xScale, yScales[0], 'x', viewId); // 绘制 x 轴
}
if (!_.isEmpty(yScales) && coordType !== 'helix') {
_.each(yScales, (yScale, index) => {
if (!this._isHide(yScale.field)) {
this._drawAxis(coord, yScale, xScale, 'y', viewId, xAxis, index);
}
});
}
}
}
function getPointsBox(points: PointObject[]) {
if (_.isEmpty(points)) {
return null;
}
let minX = points[0].x;
let maxX = points[0].x;
let minY = points[0].y;
let maxY = points[0].y;
_.each(points, (point) => {
minX = minX > point.x ? point.x : minX;
maxX = maxX < point.x ? point.x : maxX;
minY = minY > point.y ? point.y : minY;
maxY = maxY < point.y ? point.y : maxY;
});
return {
minX,
maxX,
function getPointsBox(points) {
if (isEmpty(points)) {
return null;
}
let minX = points[0].x;
let maxX = points[0].x;
let minY = points[0].y;
let maxY = points[0].y;
each(points, (point) => {
minX = minX > point.x ? point.x : minX;
maxX = maxX < point.x ? point.x : maxX;
minY = minY > point.y ? point.y : minY;
maxY = maxY < point.y ? point.y : maxY;
});
return {
minX,
function getPointsBox(points: any[]) {
if (_.isEmpty(points)) {
return null;
}
let minX = points[0].x;
let maxX = points[0].x;
let minY = points[0].y;
let maxY = points[0].y;
_.each(points, (point) => {
minX = minX > point.x ? point.x : minX;
maxX = maxX < point.x ? point.x : maxX;
minY = minY > point.y ? point.y : minY;
maxY = maxY < point.y ? point.y : maxY;
});
return {
minX,
maxX,