图表组件接入 显示成功
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
handleAlarm,
|
||||
exportAlarm
|
||||
} from '../../api/alarmApi.js';
|
||||
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../recharts.jsx';
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
const { Text } = Typography;
|
||||
@@ -250,18 +251,28 @@ export default function AlarmCenterPage() {
|
||||
}
|
||||
];
|
||||
|
||||
// 图表数据
|
||||
const pieConfig = {
|
||||
data: [
|
||||
{ type: '严重', value: statData.levelStats?.[1] || 0 },
|
||||
{ type: '重要', value: statData.levelStats?.[2] || 0 },
|
||||
{ type: '一般', value: statData.levelStats?.[3] || 0 },
|
||||
{ type: '提示', value: statData.levelStats?.[4] || 0 },
|
||||
].filter(i => i.value > 0),
|
||||
angleField: 'value', colorField: 'type',
|
||||
color: ['#FF4D4F', '#FA8C16', '#FADB14', '#1890FF'],
|
||||
radius: 0.8, innerRadius: 0.6, label: false
|
||||
};
|
||||
const pieData = [
|
||||
{
|
||||
name: '严重',
|
||||
value: statData.levelStats?.[1] || 0,
|
||||
color: '#FF4D4F',
|
||||
},
|
||||
{
|
||||
name: '重要',
|
||||
value: statData.levelStats?.[2] || 0,
|
||||
color: '#FA8C16',
|
||||
},
|
||||
{
|
||||
name: '一般',
|
||||
value: statData.levelStats?.[3] || 0,
|
||||
color: '#FADB14',
|
||||
},
|
||||
{
|
||||
name: '提示',
|
||||
value: statData.levelStats?.[4] || 0,
|
||||
color: '#1890FF',
|
||||
},
|
||||
].filter(i => i.value > 0);
|
||||
|
||||
return (
|
||||
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '16px 24px' }}>
|
||||
@@ -465,40 +476,100 @@ export default function AlarmCenterPage() {
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警趋势" style={{ borderRadius: 8 }}>
|
||||
<Line
|
||||
<UniversalLineChart
|
||||
data={[
|
||||
{ date: '00:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
{ date: '04:00', 严重: (statData.levelStats?.[1] || 0) + 1 },
|
||||
{ date: '08:00', 严重: (statData.levelStats?.[1] || 0) + 2 },
|
||||
{ date: '12:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
{ date: '16:00', 严重: (statData.levelStats?.[1] || 0) + 1 },
|
||||
{ date: '20:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
{
|
||||
date: '00:00',
|
||||
severe: statData.levelStats?.[1] || 0,
|
||||
important: statData.levelStats?.[2] || 0,
|
||||
},
|
||||
{
|
||||
date: '04:00',
|
||||
severe: (statData.levelStats?.[1] || 0) + 1,
|
||||
important: (statData.levelStats?.[2] || 0) + 2,
|
||||
},
|
||||
{
|
||||
date: '08:00',
|
||||
severe: (statData.levelStats?.[1] || 0) + 2,
|
||||
important: (statData.levelStats?.[2] || 0) + 1,
|
||||
},
|
||||
{
|
||||
date: '12:00',
|
||||
severe: statData.levelStats?.[1] || 0,
|
||||
important: statData.levelStats?.[2] || 0,
|
||||
},
|
||||
{
|
||||
date: '16:00',
|
||||
severe: (statData.levelStats?.[1] || 0) + 1,
|
||||
important: (statData.levelStats?.[2] || 0) + 1,
|
||||
},
|
||||
{
|
||||
date: '20:00',
|
||||
severe: statData.levelStats?.[1] || 0,
|
||||
important: statData.levelStats?.[2] || 0,
|
||||
},
|
||||
]}
|
||||
xField="date"
|
||||
yField={['严重']}
|
||||
color={['#FF4D4F']}
|
||||
smooth
|
||||
xKey="date"
|
||||
height={220}
|
||||
smooth
|
||||
dot
|
||||
backgroundColor="transparent"
|
||||
series={[
|
||||
{
|
||||
key: 'severe',
|
||||
name: '严重',
|
||||
color: '#FF4D4F',
|
||||
strokeWidth: 3,
|
||||
},
|
||||
{
|
||||
key: 'important',
|
||||
name: '重要',
|
||||
color: '#FA8C16',
|
||||
strokeWidth: 2,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警分类占比" style={{ borderRadius: 8 }}>
|
||||
<Pie {...pieConfig} height={220} />
|
||||
</Card>
|
||||
<UniversalPieChart
|
||||
data={pieData}
|
||||
height={220}
|
||||
innerRadius={45}
|
||||
outerRadius={80}
|
||||
backgroundColor="transparent"
|
||||
/> </Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警状态统计" style={{ borderRadius: 8 }}>
|
||||
<Bar
|
||||
<UniversalBarChart
|
||||
data={[
|
||||
{ name: '待处理', value: statData.pending || 0 },
|
||||
{ name: '处理中', value: statData.processing || 0 },
|
||||
{ name: '已关闭', value: statData.closed || 0 },
|
||||
{
|
||||
name: '待处理',
|
||||
pending: statData.pending || 0,
|
||||
},
|
||||
{
|
||||
name: '处理中',
|
||||
pending: statData.processing || 0,
|
||||
},
|
||||
{
|
||||
name: '已关闭',
|
||||
pending: statData.closed || 0,
|
||||
},
|
||||
]}
|
||||
xField="name"
|
||||
yField="value"
|
||||
color={['#165DFF']}
|
||||
xKey="name"
|
||||
height={220}
|
||||
backgroundColor="transparent"
|
||||
barSize={36}
|
||||
radius={[6, 6, 0, 0]}
|
||||
series={[
|
||||
{
|
||||
key: 'pending',
|
||||
name: '数量',
|
||||
color: '#165DFF',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
@@ -463,16 +463,72 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
|
||||
{/* 条件渲染:机器人显示其余信息(此处以任务详情为例) */}
|
||||
{(!selectedDevice?.productName?.includes('无人机') && !selectedDevice?.device_sn) && (
|
||||
<Card title={<><RobotOutlined /> 机器人作业状态</>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
|
||||
<Row gutter={16}>
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}>
|
||||
<RobotOutlined style={{ color: '#165DFF' }} />
|
||||
机器人作业状态
|
||||
</div>
|
||||
}
|
||||
bordered={false}
|
||||
style={{
|
||||
borderRadius: 12,
|
||||
marginBottom: 16,
|
||||
boxShadow: '0 2px 8px rgba(0,0,0,0.06)',
|
||||
border: '1px solid #f0f0f0',
|
||||
}}
|
||||
>
|
||||
<Row gutter={16} style={{ alignItems: 'center' }}>
|
||||
<Col span={8}>
|
||||
<Statistic title="累计里程" value={128.5} suffix="km" valueStyle={{ fontSize: 20 }} />
|
||||
<div
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
borderRadius: 8,
|
||||
background: '#f8fafc',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 12, color: '#86909C' }}>累计里程</span>}
|
||||
value={128.5}
|
||||
suffix="km"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Statistic title="本次作业耗时" value={45} suffix="min" valueStyle={{ fontSize: 20 }} />
|
||||
<div
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
borderRadius: 8,
|
||||
background: '#f8fafc',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 12, color: '#86909C' }}>本次作业耗时</span>}
|
||||
value={45}
|
||||
suffix="min"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Statistic title="预计剩余时间" value={12} suffix="min" valueStyle={{ fontSize: 20 }} />
|
||||
<div
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
borderRadius: 8,
|
||||
background: '#f8fafc',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 12, color: '#86909C' }}>预计剩余时间</span>}
|
||||
value={12}
|
||||
suffix="min"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
@@ -75,6 +75,7 @@ export const UniversalLineChart = ({
|
||||
name={item.name}
|
||||
stroke={item.color || DEFAULT_COLORS[index % DEFAULT_COLORS.length]}
|
||||
strokeWidth={item.strokeWidth || 2}
|
||||
strokeDasharray={item.dashed ? '6 6' : undefined}
|
||||
dot={dot}
|
||||
activeDot={{ r: 6 }}
|
||||
/>
|
||||
@@ -151,11 +152,12 @@ export const UniversalPieChart = ({
|
||||
showLegend = true,
|
||||
showTooltip = true,
|
||||
backgroundColor = '#ffffff',
|
||||
innerRadius = 60,
|
||||
outerRadius = 120,
|
||||
innerRadius = 40,
|
||||
outerRadius = 60,
|
||||
paddingAngle = 2,
|
||||
showLabel = true,
|
||||
className,
|
||||
style
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
@@ -166,6 +168,7 @@ export const UniversalPieChart = ({
|
||||
background: backgroundColor,
|
||||
borderRadius: 12,
|
||||
padding: 12,
|
||||
...style
|
||||
}}
|
||||
>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
|
||||
Reference in New Issue
Block a user