Spaces:
Sleeping
Sleeping
File size: 1,261 Bytes
ef785b2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import ReactECharts from 'echarts-for-react'
function RadarChart({ dimensions = [], scores = [], loading = false }) {
if (loading) {
return (
<div className="loading-state" style={{ height: 320 }}>
<div className="loading-spinner loading-spinner-lg" />
<p className="text-secondary mt-16">加载中...</p>
</div>
)
}
const isEmpty = !dimensions.length || !scores.length || scores.every((s) => s === 0)
if (isEmpty) {
return (
<div className="flex-center" style={{ height: 320 }}>
<p className="text-secondary">图表数据暂不可用</p>
</div>
)
}
const option = {
radar: {
indicator: dimensions.map((name) => ({ name, max: 100 })),
center: ['50%', '50%'],
radius: '65%',
},
series: [
{
type: 'radar',
data: [{ value: scores, name: '匹配得分' }],
areaStyle: { color: 'rgba(79, 70, 229, 0.2)' },
lineStyle: { color: '#4F46E5' },
itemStyle: { color: '#4F46E5' },
},
],
animationDuration: 1000,
animationEasing: 'cubicOut',
}
return (
<div style={{ height: 320 }}>
<ReactECharts option={option} style={{ height: '100%' }} />
</div>
)
}
export default RadarChart
|