feat: 雷达图展示优化
This commit is contained in:
@@ -92,12 +92,34 @@ const RadarChart: React.FC = forwardRef((props, ref) => {
|
||||
});
|
||||
|
||||
// === 数据区域 ===
|
||||
// ctx.beginPath();
|
||||
// values.forEach((val, i) => {
|
||||
// const angle = ((Math.PI * 2) / labels.length) * i - Math.PI / 2;
|
||||
// const r = (val / maxValue) * radius;
|
||||
// const x = center.x + r * Math.cos(angle);
|
||||
// const y = center.y + r * Math.sin(angle);
|
||||
// if (i === 0) ctx.moveTo(x, y);
|
||||
// else ctx.lineTo(x, y);
|
||||
// });
|
||||
// ctx.closePath();
|
||||
// ctx.fillStyle = "rgba(0,200,180,0.3)";
|
||||
// ctx.fill();
|
||||
// ctx.strokeStyle = "#00c8b4";
|
||||
// ctx.lineWidth = 3;
|
||||
// ctx.stroke();
|
||||
const baseRadius = (radius / levels) * 1; // 第二个环为起点
|
||||
const usableRadius = radius - baseRadius;
|
||||
|
||||
ctx.beginPath();
|
||||
values.forEach((val, i) => {
|
||||
const angle = ((Math.PI * 2) / labels.length) * i - Math.PI / 2;
|
||||
const r = (val / maxValue) * radius;
|
||||
|
||||
// 关键修改:值从第二个环开始
|
||||
const r = baseRadius + (val / maxValue) * usableRadius;
|
||||
|
||||
const x = center.x + r * Math.cos(angle);
|
||||
const y = center.y + r * Math.sin(angle);
|
||||
|
||||
if (i === 0) ctx.moveTo(x, y);
|
||||
else ctx.lineTo(x, y);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user