feat: 可视化大屏展示

This commit is contained in:
2025-12-30 17:14:17 +08:00
parent 02f9b46b22
commit fb40fce9cd
15 changed files with 2195 additions and 44 deletions
+26 -24
View File
@@ -8,7 +8,7 @@ import {
EnvironmentOutlined,
PieChartOutlined
} from '@ant-design/icons';
import { Line, Pie, Column, Area, Gauge, Rose } from '@ant-design/plots';
import { Line, Pie, Column, Area, Rose } from '@ant-design/plots';
import { history } from 'umi';
import dayjs from 'dayjs';
import {
@@ -169,8 +169,14 @@ const Dashboard: React.FC = () => {
radius: 0.7,
innerRadius: 0.5,
label: {
type: 'outer',
content: '{name} {percentage}',
text: (datum: any) => {
const name = datum?.name || '';
const count = datum?.count ?? 0;
const data = (deviceStats?.byType || []) as { name: string; count: number }[];
const total = data.reduce((sum, d) => sum + (d.count || 0), 0);
const percent = total > 0 ? ((count / total) * 100).toFixed(1) : 0;
return `${name} ${percent}%`;
},
style: { fill: 'rgba(255,255,255,0.65)' },
},
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(255,255,255,0.65)' } }, itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
@@ -192,7 +198,7 @@ const Dashboard: React.FC = () => {
return '#8b9dc3';
},
label: {
position: 'middle',
text: (datum: any) => datum?.value?.toString() || '0',
style: { fill: '#fff' },
},
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } } },
@@ -230,7 +236,7 @@ const Dashboard: React.FC = () => {
smooth: true,
height: 220,
};
const roseConfig: any = {
data: failureAnalysisData,
xField: 'type',
@@ -238,8 +244,7 @@ const Dashboard: React.FC = () => {
seriesField: 'type',
radius: 0.9,
label: {
offset: -15,
content: '{name}',
text: (datum: any) => datum?.type || '',
style: { fill: '#fff' },
},
legend: { position: 'bottom', itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
@@ -258,8 +263,13 @@ const Dashboard: React.FC = () => {
radius: 0.85,
innerRadius: 0.55,
label: {
type: 'outer',
content: '{name} {percentage}',
text: (datum: any) => {
const name = datum?.name || '';
const value = datum?.value ?? 0;
const total = (taskStats?.pending || 0) + (taskStats?.running || 0) + (taskStats?.completed || 0) + (taskStats?.failed || 0);
const percent = total > 0 ? ((value / total) * 100).toFixed(1) : 0;
return `${name} ${percent}%`;
},
style: { fill: 'rgba(255,255,255,0.65)' },
},
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(255,255,255,0.65)' } }, itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
@@ -457,21 +467,13 @@ const Dashboard: React.FC = () => {
<div className="lbl">已失败</div>
</div>
</div>
<div style={{ marginTop: 16 }}>
<Gauge
percent={taskStats?.successRate ? taskStats.successRate / 100 : 0}
range={{ color: 'l(0) 0:#bde8ff 1:#9ec9ff' }}
startAngle={Math.PI}
endAngle={2 * Math.PI}
indicator={null}
statistic={{
content: {
style: { fontSize: '20px', color: '#fff' },
formatter: () => `${taskPeriodText}成功率`,
},
}}
height={100}
/>
<div style={{ marginTop: 16, textAlign: 'center' }}>
<div style={{ fontSize: '32px', fontWeight: 'bold', color: '#00ff88' }}>
{taskStats?.successRate || 0}%
</div>
<div style={{ fontSize: '14px', color: '#fff', marginTop: 4 }}>
{taskPeriodText}成功率
</div>
</div>
</Card>