Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
radius,
0,
1,
1,
2 * coordCenter.x - start.x,
2 * coordCenter.y - start.y,
],
[ 'A', radius, radius, 0, 1, 1, start.x, start.y ],
];
}
} else {
// 只适用于start和end,yScale值相同,需要判断scale结果
// 求向量 center -> start 和 center -> end 的顺时针角度
// 即等于求 start -> center 和 end -> center 的逆时针角度
const dAngle = vec2.angleTo(
[ coordCenter.x - start.x, coordCenter.y - start.y ],
[ coordCenter.x - end.x, coordCenter.y - end.y ],
0,
);
const largeArc = dAngle > Math.PI ? 1 : 0;
path = [
[ 'M', start.x, start.y ],
[ 'A', radius, radius, 0, largeArc, 1, end.x, end.y ],
];
}
const arcShape = group.addShape('path', {
zIndex: this.get('zIndex'),
attrs: _.assign({ path }, this.get('style')),
});
arcShape.name = 'annotation-arc'; // 用于事件以及动画识别
const labelOffset = Util.get(this.get('label'), 'offset', 5);
titleOffset += labelLength + labelOffset;
}
// }
const textStyle = title.textStyle;
const cfg = Util.mix({}, textStyle);
if (title.text) {
const vector = this.getAxisVector(); // 坐标轴方向的向量
if (autoRotateTitle && Util.isNil(title.rotate)) {
// 自动旋转并且用户没有设置 title.rotate
let angle = 0;
if (!Util.isNumberEqual(vector[1], 0)) {
// 所有水平坐标轴,文本不转置
const v1 = [1, 0];
const v2 = [vector[0], vector[1]];
angle = vec2.angleTo(v2, v1, true);
}
cfg.rotate = angle * (180 / Math.PI);
} else if (!Util.isNil(title.rotate)) {
// 用户设置了旋转角度就以用户设置的为准
cfg.rotate = (title.rotate / 180) * Math.PI; // 将角度转换为弧度
}
const sideVector = this.getSideVector(titleOffset);
let point;
const position = title.position;
if (position === 'start') {
point = {
x: this.get('start').x + sideVector[0],
y: this.get('start').y + sideVector[1],
};