图表组件接入 显示成功

This commit is contained in:
mmc
2026-05-14 15:15:50 +08:00
parent abe5631642
commit adf4c37b95
9 changed files with 673 additions and 487 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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%">

View File

@@ -11,7 +11,7 @@ import {
SelectOutlined, FireOutlined, WarningOutlined, ExclamationCircleOutlined
} from '@ant-design/icons';
import { Line, Area } from '@ant-design/charts';
import { UniversalBarChart, UniversalLineChart } from "../components/recharts"
import { UniversalLineChart } from "../components/recharts"
const { Title, Text } = Typography;
@@ -39,82 +39,101 @@ const thermalImagingData = [
{ name: '方阵 C-07', temp: '67.2℃', id: 'C07', status: 'warning' },
];
// 图表配置
const degradationConfig = {
data: [
{ date: '2024-01', type: '平均衰减率', value: 0 },
{ date: '2024-04', type: '平均衰减率', value: -1.2 },
{ date: '2024-07', type: '平均衰减率', value: -2.5 },
{ date: '2024-10', type: '平均衰减率', value: -3.8 },
{ date: '2025-01', type: '平均衰减率', value: -4.5 },
{ date: '2025-05', type: '平均衰减率', value: -5.32 },
{ date: '2024-01', type: '最佳组件', value: 0 },
{ date: '2024-04', type: '最佳组件', value: -0.5 },
{ date: '2024-07', type: '最佳组件', value: -1.0 },
{ date: '2024-10', type: '最佳组件', value: -1.5 },
{ date: '2025-01', type: '最佳组件', value: -2.0 },
{ date: '2025-05', type: '最佳组件', value: -2.5 },
{ date: '2024-01', type: '最差组件', value: -1.0 },
{ date: '2024-04', type: '最差组件', value: -2.5 },
{ date: '2024-07', type: '最差组件', value: -4.0 },
{ date: '2024-10', type: '最差组件', value: -6.5 },
{ date: '2025-01', type: '最差组件', value: -8.0 },
{ date: '2025-05', type: '最差组件', value: -10.2 },
],
xField: 'date',
yField: 'value',
seriesField: 'type',
color: ['#165DFF', '#00B42A', '#F53F3F'],
smooth: true,
lineStyle: (type: string) => {
if (type === '最差组件') return { lineDash: [4, 4] };
return { lineWidth: 2 };
const degradationData = [
{
date: '2024-01',
average: 0,
best: 0,
worst: -1.0,
},
legend: { position: 'top' },
yAxis: { label: { formatter: (v: string) => `${v}%` } },
};
{
date: '2024-04',
average: -1.2,
best: -0.5,
worst: -2.5,
},
{
date: '2024-07',
average: -2.5,
best: -1.0,
worst: -4.0,
},
{
date: '2024-10',
average: -3.8,
best: -1.5,
worst: -6.5,
},
{
date: '2025-01',
average: -4.5,
best: -2.0,
worst: -8.0,
},
{
date: '2025-05',
average: -5.32,
best: -2.5,
worst: -10.2,
},
];
const generationPerformanceConfig = {
data: [
{ time: '00:00', type: '实际发电', value: 0 },
{ time: '03:00', type: '实际发电', value: 0 },
{ time: '06:00', type: '实际发电', value: 100 },
{ time: '09:00', type: '实际发电', value: 800 },
{ time: '12:00', type: '实际发电', value: 1400 },
{ time: '15:00', type: '实际发电', value: 1200 },
{ time: '18:00', type: '实际发电', value: 400 },
{ time: '21:00', type: '实际发电', value: 0 },
{ time: '24:00', type: '实际发电', value: 0 },
{ time: '00:00', type: '预测发电', value: 0 },
{ time: '03:00', type: '预测发电', value: 0 },
{ time: '06:00', type: '预测发电', value: 150 },
{ time: '09:00', type: '预测发电', value: 950 },
{ time: '12:00', type: '预测发电', value: 1650 },
{ time: '15:00', type: '预测发电', value: 1350 },
{ time: '18:00', type: '预测发电', value: 550 },
{ time: '21:00', type: '预测发电', value: 0 },
{ time: '24:00', type: '预测发电', value: 0 },
{ time: '00:00', type: '理论发电', value: 0 },
{ time: '03:00', type: '理论发电', value: 0 },
{ time: '06:00', type: '理论发电', value: 200 },
{ time: '09:00', type: '理论发电', value: 1100 },
{ time: '12:00', type: '理论发电', value: 1800 },
{ time: '15:00', type: '理论发电', value: 1500 },
{ time: '18:00', type: '理论发电', value: 650 },
{ time: '21:00', type: '理论发电', value: 0 },
{ time: '24:00', type: '理论发电', value: 0 },
],
xField: 'time',
yField: 'value',
seriesField: 'type',
color: ['#165DFF', '#00B42A', '#86909C'],
smooth: true,
lineStyle: (type: string) => {
if (type === '理论发电') return { lineDash: [4, 4] };
return { lineWidth: 2 };
const generationPerformanceData = [
{
time: '00:00',
actual: 0,
predict: 0,
theory: 0,
},
legend: { position: 'top' },
};
{
time: '03:00',
actual: 0,
predict: 0,
theory: 0,
},
{
time: '06:00',
actual: 100,
predict: 150,
theory: 200,
},
{
time: '09:00',
actual: 800,
predict: 950,
theory: 1100,
},
{
time: '12:00',
actual: 1400,
predict: 1650,
theory: 1800,
},
{
time: '15:00',
actual: 1200,
predict: 1350,
theory: 1500,
},
{
time: '18:00',
actual: 400,
predict: 550,
theory: 650,
},
{
time: '21:00',
actual: 0,
predict: 0,
theory: 0,
},
{
time: '24:00',
actual: 0,
predict: 0,
theory: 0,
},
];
export default function AIDiagnosisPage() {
@@ -369,8 +388,35 @@ export default function AIDiagnosisPage() {
<span>衰减率趋势 (%)</span>
<span style={{ color: '#F53F3F', fontWeight: 600 }}>当前均值: -5.32%</span>
</div>
<Line {...degradationConfig} height={240} autoFit />
<div style={{ marginTop: 16, padding: '12px', background: '#FFF7E8', borderRadius: 8, border: '1px solid #FFE4BA' }}>
<UniversalLineChart
data={degradationData}
xKey="date"
height={240}
smooth
dot
showGrid
showLegend
series={[
{
key: 'average',
name: '平均衰减率',
color: '#165DFF',
strokeWidth: 3,
},
{
key: 'best',
name: '最佳组件',
color: '#00B42A',
strokeWidth: 2,
},
{
key: 'worst',
name: '最差组件',
color: '#F53F3F',
strokeWidth: 2,
},
]}
/> <div style={{ marginTop: 16, padding: '12px', background: '#FFF7E8', borderRadius: 8, border: '1px solid #FFE4BA' }}>
<div style={{ fontSize: 12, color: '#86909C', display: 'flex', alignItems: 'center' }}>
<ExclamationCircleOutlined style={{ color: '#FF7D00', marginRight: 6 }} />
<span style={{ color: '#1D2129', fontWeight: 600 }}>衰减预警:</span>
@@ -390,8 +436,35 @@ export default function AIDiagnosisPage() {
<div style={{ display: 'flex', gap: 20 }}>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 16 }}>发电量对比分析 (kWh)</div>
<Line {...generationPerformanceConfig} height={240} autoFit />
</div>
<UniversalLineChart
data={generationPerformanceData}
xKey="time"
height={240}
smooth
dot={false}
showGrid
showLegend
series={[
{
key: 'actual',
name: '实际发电',
color: '#165DFF',
strokeWidth: 3,
},
{
key: 'predict',
name: '预测发电',
color: '#00B42A',
strokeWidth: 2,
},
{
key: 'theory',
name: '理论发电',
color: '#86909C',
strokeWidth: 2,
},
]}
/> </div>
<div style={{ width: 120, display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: 16, flexShrink: 0, paddingLeft: 16, borderLeft: '1px solid #f0f0f0' }}>
{[
{ label: '当日实际发电', value: '4,752', unit: 'kWh', color: '#165DFF' },

View File

@@ -29,6 +29,7 @@ import {
ShieldCheck,
Leaf
} from 'lucide-react';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
const { Title, Text } = Typography;
const { RangePicker } = DatePicker;
@@ -51,22 +52,21 @@ const workOrderPreviewData = [
{ area: '区块 05', priority: '中', duration: '2.2 h', handler: '赵工', planTime: '2025-05-29 - 05-30', status: '待创建' },
];
// 图表配置数据
const pollutionTrendData = [
{ date: '05-18', value: 78, type: '污染指数' },
{ date: '05-19', value: 72, type: '污染指数' },
{ date: '05-20', value: 65, type: '污染指数' },
{ date: '05-21', value: 75, type: '污染指数' },
{ date: '05-22', value: 68, type: '污染指数' },
{ date: '05-23', value: 60, type: '污染指数' },
{ date: '05-24', value: 68.5, type: '污染指数' },
const pollutionLineData = [
{ date: '05-18', pollution: 78, threshold: 75 },
{ date: '05-19', pollution: 72, threshold: 75 },
{ date: '05-20', pollution: 65, threshold: 75 },
{ date: '05-21', pollution: 75, threshold: 75 },
{ date: '05-22', pollution: 68, threshold: 75 },
{ date: '05-23', pollution: 60, threshold: 75 },
{ date: '05-24', pollution: 68.5, threshold: 75 },
];
const lossPieData = [
{ type: '灰尘积累', value: 6120, color: '#165DFF' },
{ type: '鸟粪遮挡', value: 1480, color: '#F53F3F' },
{ type: '沙尘沉积', value: 1120, color: '#F7BA1E' },
{ type: '其他', value: 600, color: '#86909C' },
const pieChartData = [
{ name: '灰尘积累', value: 6120, color: '#165DFF' },
{ name: '鸟粪遮挡', value: 1480, color: '#F53F3F' },
{ name: '沙尘沉积', value: 1120, color: '#F7BA1E' },
{ name: '其他', value: 600, color: '#86909C' },
];
const dualAxesData = [
@@ -97,21 +97,14 @@ const dualAxesData = [
],
];
const compareBarData = [
{ date: 'D-7', value: 800, type: '清洗前发电量(kWh)' },
{ date: 'D-7', value: 1200, type: '清洗后发电量(kWh)' },
{ date: 'D-6', value: 850, type: '清洗前发电量(kWh)' },
{ date: 'D-6', value: 1250, type: '清洗后发电量(kWh)' },
{ date: 'D-5', value: 900, type: '清洗前发电量(kWh)' },
{ date: 'D-5', value: 1300, type: '清洗后发电量(kWh)' },
{ date: 'D-4', value: 880, type: '清洗前发电量(kWh)' },
{ date: 'D-4', value: 1280, type: '清洗后发电量(kWh)' },
{ date: 'D-3', value: 920, type: '清洗前发电量(kWh)' },
{ date: 'D-3', value: 1320, type: '清洗后发电量(kWh)' },
{ date: 'D-2', value: 950, type: '清洗前发电量(kWh)' },
{ date: 'D-2', value: 1350, type: '清洗后发电量(kWh)' },
{ date: 'D-1', value: 980, type: '清洗前发电量(kWh)' },
{ date: 'D-1', value: 1380, type: '清洗后发电量(kWh)' },
const compareChartData = [
{ date: 'D-7', before: 800, after: 1200 },
{ date: 'D-6', before: 850, after: 1250 },
{ date: 'D-5', before: 900, after: 1300 },
{ date: 'D-4', before: 880, after: 1280 },
{ date: 'D-3', before: 920, after: 1320 },
{ date: 'D-2', before: 950, after: 1350 },
{ date: 'D-1', before: 980, after: 1380 },
];
@@ -307,38 +300,37 @@ export default function CleanOptimizationPage() {
<span style={{ display: 'flex', alignItems: 'center' }}><div style={{ width: 8, height: 2, borderBottom: '1px dashed #F53F3F', marginRight: 4 }}></div>阈值</span>
</Space>
</div>
<Line
data={pollutionTrendData}
xField="date"
yField="value"
seriesField="type"
color={['#1890ff', '#ff4d4f']}
lineStyle={(type) => {
if (type === '阈值') return { lineDash: [4, 4] };
return {};
}}
legend={{ position: 'top-right' }}
height={120}
padding={[10, 10, 30, 30]}
<UniversalLineChart
data={pollutionLineData}
xKey="date"
height={180}
dot
series={[
{
key: 'pollution',
name: '污染指数',
color: '#1890ff',
strokeWidth: 3,
},
{
key: 'threshold',
name: '阈值',
color: '#ff4d4f',
dashed: true,
strokeWidth: 2,
},
]}
/>
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>发电损失构成 <Text type="secondary" style={{ fontWeight: 400, fontSize: 12 }}>(近 7 天)</Text></span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<div style={{ position: 'relative', height: 180 }}>
<Pie
data={lossPieData}
angleField="value"
colorField="type"
radius={0.8}
innerRadius={0.65}
color={['#165DFF', '#F53F3F', '#F7BA1E', '#86909C']}
legend={{
position: 'right',
layout: 'vertical',
itemValue: { formatter: (val, item) => `${item.value} kWh` }
}}
height={180}
autoFit
<div style={{ position: 'relative', height: "100%" }}>
<UniversalPieChart
data={pieChartData}
height={220}
innerRadius={50}
outerRadius={80}
showLabel={false}
/>
<div style={{ position: 'absolute', left: '30%', top: '50%', transform: 'translate(-50%, -50%)', textAlign: 'center' }}>
<div style={{ fontSize: 10, color: '#86909C' }}>总损失电量</div>
@@ -349,16 +341,23 @@ export default function CleanOptimizationPage() {
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>清洗前后对比分析 <Text type="secondary" style={{ fontWeight: 400, fontSize: 12 }}>(近一次)</Text></span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<Column
data={compareBarData}
xField="date"
yField="value"
isGroup
seriesField="type"
color={['#1890ff', '#52c41a']}
height={140}
legend={{ position: 'top', layout: 'horizontal' }}
padding={[30, 10, 30, 30]}
<UniversalBarChart
data={compareChartData}
xKey="date"
height={220}
barSize={18}
series={[
{
key: 'before',
name: '清洗前发电量(kWh)',
color: '#1890ff',
},
{
key: 'after',
name: '清洗后发电量(kWh)',
color: '#52c41a',
},
]}
/>
</Card>

View File

@@ -18,6 +18,7 @@ import { Line, Bar, Pie, } from '@ant-design/charts';
import { getWeatherData, getWeatherType } from '../lib/utils';
import WeatherDisplay from '../components/Weather';
import bgMain from '../assets/images/bgmain.jpg';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
@@ -90,180 +91,47 @@ export default function StationDashboard() {
];
// 图表配置 —— 终极美化版(渐变+紧凑+高级)
const powerTrendConfig = {
data: [
{ time: "00:00", type: "实际", value: 1800 },
{ time: "00:00", type: "预测", value: 1600 },
{ time: "04:00", type: "实际", value: 1500 },
{ time: "04:00", type: "预测", value: 1400 },
{ time: "06:00", type: "实际", value: 8000 },
{ time: "06:00", type: "预测", value: 7500 },
{ time: "08:00", type: "实际", value: 32000 },
{ time: "08:00", type: "预测", value: 30000 },
{ time: "10:00", type: "实际", value: 58000 },
{ time: "10:00", type: "预测", value: 56000 },
{ time: "12:00", type: "实际", value: 62000 },
{ time: "12:00", type: "预测", value: 60000 },
{ time: "14:00", type: "实际", value: 59000 },
{ time: "14:00", type: "预测", value: 57000 },
{ time: "16:00", type: "实际", value: 42000 },
{ time: "16:00", type: "预测", value: 40000 },
{ time: "18:00", type: "实际", value: 12000 },
{ time: "18:00", type: "预测", value: 10000 },
{ time: "20:00", type: "实际", value: 3000 },
{ time: "20:00", type: "预测", value: 2500 },
{ time: "24:00", type: "实际", value: 1800 },
{ time: "24:00", type: "预测", value: 1600 }
],
const powerTrendData = [
{ time: '00:00', actual: 1800, predict: 1600 },
{ time: '04:00', actual: 1500, predict: 1400 },
{ time: '06:00', actual: 8000, predict: 7500 },
{ time: '08:00', actual: 32000, predict: 30000 },
{ time: '10:00', actual: 58000, predict: 56000 },
{ time: '12:00', actual: 62000, predict: 60000 },
{ time: '14:00', actual: 59000, predict: 57000 },
{ time: '16:00', actual: 42000, predict: 40000 },
{ time: '18:00', actual: 12000, predict: 10000 },
{ time: '20:00', actual: 3000, predict: 2500 },
{ time: '24:00', actual: 1800, predict: 1600 },
];
xField: 'time',
yField: 'value',
seriesField: 'type',
smooth: true,
color: ['#165DFF', '#00B42A'], // ✅ 两条线颜色
lineStyle: { lineWidth: 2 },
point: { size: 5, shape: 'circle' },
area: false,
legend: { position: 'top-left' },
yAxis: { min: 0, max: 68000 },
};
const irradianceData = [
{ time: '00:00', irradiance: 40, temperature: 14 },
{ time: '04:00', irradiance: 30, temperature: 12 },
{ time: '06:00', irradiance: 180, temperature: 16 },
{ time: '08:00', irradiance: 460, temperature: 21 },
{ time: '10:00', irradiance: 780, temperature: 27 },
{ time: '12:00', irradiance: 860, temperature: 31 },
{ time: '14:00', irradiance: 820, temperature: 30 },
{ time: '16:00', irradiance: 620, temperature: 26 },
{ time: '18:00', irradiance: 220, temperature: 20 },
{ time: '20:00', irradiance: 60, temperature: 16 },
{ time: '24:00', irradiance: 40, temperature: 14 },
];
const invEfficiencyData = [
{ device: 'INV-01', efficiency: 98.6 },
{ device: 'INV-02', efficiency: 97.8 },
{ device: 'INV-03', efficiency: 97.2 },
{ device: 'INV-04', efficiency: 96.5 },
{ device: 'INV-05', efficiency: 95.8 },
];
const irradianceConfig = {
// 👇 我已经帮你把数据改成支持多色的格式
data: [
{ time: "00:00", name: "辐照度", value: 40 },
{ time: "00:00", name: "温度", value: 14 },
{ time: "04:00", name: "辐照度", value: 30 },
{ time: "04:00", name: "温度", value: 12 },
{ time: "06:00", name: "辐照度", value: 180 },
{ time: "06:00", name: "温度", value: 16 },
{ time: "08:00", name: "辐照度", value: 460 },
{ time: "08:00", name: "温度", value: 21 },
{ time: "10:00", name: "辐照度", value: 780 },
{ time: "10:00", name: "温度", value: 27 },
{ time: "12:00", name: "辐照度", value: 860 },
{ time: "12:00", name: "温度", value: 31 },
{ time: "14:00", name: "辐照度", value: 820 },
{ time: "14:00", name: "温度", value: 30 },
{ time: "16:00", name: "辐照度", value: 620 },
{ time: "16:00", name: "温度", value: 26 },
{ time: "18:00", name: "辐照度", value: 220 },
{ time: "18:00", name: "温度", value: 20 },
{ time: "20:00", name: "辐照度", value: 60 },
{ time: "20:00", name: "温度", value: 16 },
{ time: "24:00", name: "辐照度", value: 40 },
{ time: "24:00", name: "温度", value: 14 },
],
xField: "time",
yField: "value", // 现在只用一个 value
seriesField: "name", // 按 name 区分两条线
smooth: true,
color: ["#165DFF", "#00B42A"],
point: {
size: 5,
shape: "circle",
},
area: false,
animation: {
appear: {
animation: "path-in",
duration: 1500,
},
},
grid: {
line: {
style: {
stroke: "#eee",
lineWidth: 0.5,
},
},
},
legend: {
position: "top-left",
},
yAxis: {
min: 0,
max: 900,
tickCount: 6,
},
};
const invEfficiencyConfig = {
data: [
{ device: 'INV-01', efficiency: 98.6 },
{ device: 'INV-02', efficiency: 97.8 },
{ device: 'INV-03', efficiency: 97.2 },
{ device: 'INV-04', efficiency: 96.5 },
{ device: 'INV-05', efficiency: 95.8 }
],
// 恢复为竖向柱状图:X轴是设备,Y轴是效率
xField: 'device',
yField: 'efficiency',
// 每个柱子不同颜色,效率越高越亮
color: ({ efficiency }) => {
if (efficiency >= 98) return '#00B42A'; // 亮绿(最高效)
if (efficiency >= 97) return '#52C41A'; // 草绿
if (efficiency >= 96) return '#1890FF'; // 天蓝
if (efficiency >= 95) return '#4080FF'; // 蓝色
return '#808695'; // 灰色(最低效)
},
barStyle: {
radius: [4, 4, 0, 0] // 顶部圆角,和第二张图效果一致
},
// 标签放在柱子顶部,显示百分比
label: {
position: 'top',
style: {
fontSize: 11,
fill: '#333',
fontWeight: 600
},
formatter: (item) => `${item}%`
},
// Y轴从60开始(和第二张图的刻度一致),让柱子更饱满
yAxis: {
min: 60,
max: 100,
tickCount: 5, // 控制刻度数量,显示60/70/80/90/100
label: {
formatter: (v) => `${v}`
}
},
// 隐藏X轴上的线,保持简洁
xAxis: {
line: null
},
grid: {
line: { style: { stroke: '#eee', lineWidth: 0.5 } }
},
animation: { appear: { animation: 'scale-in-y', duration: 1000 } }
};
const taskProgressConfig = {
data: [
{ type: '已完成', value: 40 },
{ type: '进行中', value: 35 },
{ type: '待开始', value: 20 },
{ type: '异常', value: 5 }
],
angleField: 'value',
colorField: 'type',
color: ['#1890ff', '#52c41a', '#faad14', '#ff4d4f'],
radius: 0.8,
innerRadius: 0.6,
legend: { position: 'right' }
};
const taskProgressData = [
{ name: '已完成', value: 40, color: '#1890ff' },
{ name: '进行中', value: 35, color: '#52c41a' },
{ name: '待开始', value: 20, color: '#faad14' },
{ name: '异常', value: 5, color: '#ff4d4f' },
];
const cardStyle = { borderRadius: 12, border: '1px solid #f0f0f0', boxShadow: '0 2px 8px rgba(0,0,0,0.04)' };
@@ -325,18 +193,77 @@ export default function StationDashboard() {
<Space direction="vertical" size={16} style={{ width: '100%' }}>
<Card title={<span style={{ fontWeight: 800 }}>发电趋势</span>} extra={<Space><SyncOutlined /><FullscreenOutlined /></Space>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ fontSize: 12, color: '#666', marginBottom: 12 }}>今日发电功率趋势 (kW)</div>
<Line {...powerTrendConfig} height={180} />
</Card>
<UniversalLineChart
data={powerTrendData}
xKey="time"
height={220}
smooth
dot
backgroundColor="transparent"
series={[
{
key: 'actual',
name: '实际',
color: '#165DFF',
strokeWidth: 3,
},
{
key: 'predict',
name: '预测',
color: '#00B42A',
strokeWidth: 2,
},
]}
/> </Card>
<Card title={<span style={{ fontWeight: 800 }}>辐照度与温度趋势</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<Line {...irradianceConfig} height={180} />
</Card>
<UniversalLineChart
data={irradianceData}
xKey="time"
height={220}
smooth
dot
backgroundColor="transparent"
series={[
{
key: 'irradiance',
name: '辐照度',
color: '#165DFF',
strokeWidth: 3,
},
{
key: 'temperature',
name: '温度',
color: '#00B42A',
strokeWidth: 2,
},
]}
/> </Card>
<Card title={<span style={{ fontWeight: 800 }}>逆变器效率对比</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<Bar {...invEfficiencyConfig} height={180} />
</Card>
<UniversalBarChart
data={invEfficiencyData}
xKey="device"
height={220}
backgroundColor="transparent"
barSize={28}
radius={[6, 6, 0, 0]}
series={[
{
key: 'efficiency',
name: '效率',
color: '#165DFF',
},
]}
/> </Card>
<Card title={<span style={{ fontWeight: 800 }}>运维任务进度</span>} extra={<Button type="link" size="small">更多 &gt;</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<Pie {...taskProgressConfig} height={160} width={160} />
<div style={{ flex: 1, paddingLeft: 12 }}>
<UniversalPieChart
data={taskProgressData}
width={220}
height={220}
innerRadius={45}
outerRadius={70}
backgroundColor="transparent"
/> <div style={{ flex: 1, paddingLeft: 12 }}>
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 12, color: '#999' }}>总任务</div>
<div style={{ fontSize: 20, fontWeight: 800 }}>12</div>

View File

@@ -14,6 +14,7 @@ import {
} from '@ant-design/icons';
import { Line, Bar, Pie } from '@ant-design/charts';
import bgMain from '../assets/images/bgmain.jpg';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
const { Option } = Select;
const { Search } = Input;
@@ -203,30 +204,41 @@ const RealTimeMonitorPage = () => {
{/* 实时功率曲线 */}
<Card title={<span style={{ fontWeight: 800 }}>实时功率曲线</span>} extra={<Select defaultValue="today" size="small"><Option value="today">今天</Option></Select>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<Line
data={powerTrendData}
xField="time"
yField="value"
seriesField="type"
<UniversalLineChart
height={180}
data={powerTrendData}
xKey="time"
smooth
area={{ style: { fill: 'l(270) 0:#ffffff 0.5:#165DFF 1:#165DFF', fillOpacity: 0.1 } }}
color={['#165DFF']}
xAxis={{ tickCount: 5 }}
yAxis={{ title: { text: '功率 (kW)', style: { fontSize: 10 } } }}
dot
showLegend={false}
backgroundColor="transparent"
series={[
{
key: 'value',
name: '实时功率',
color: '#1677ff',
strokeWidth: 3,
},
]}
/>
</Card>
{/* 逆变器功率对比 */}
<Card title={<span style={{ fontWeight: 800 }}>逆变器功率对比 (实时)</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<Bar
data={inverterPowerData}
xField="name"
yField="power"
<UniversalBarChart
height={180}
color="#165DFF"
columnStyle={{ radius: [4, 4, 0, 0] }}
label={{ position: 'top', style: { fill: '#000', fontSize: 10 } }}
data={inverterPowerData}
xKey="name"
barSize={22}
showLegend={false}
backgroundColor="transparent"
series={[
{
key: 'power',
name: '实时功率',
color: '#1677ff',
},
]}
/>
</Card>
@@ -274,19 +286,30 @@ const RealTimeMonitorPage = () => {
<Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>设备在线率</span>} bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '12px' }}>
<div style={{ position: 'relative', height: 160 }}>
<Pie
<UniversalPieChart
height={160}
backgroundColor="transparent"
showLegend={false}
showLabel={false}
innerRadius={45}
outerRadius={65}
data={[
{ type: '在线', value: 52 },
{ type: '离线', value: 3 },
{ type: '告警', value: 1 }
{
name: '在线',
value: 52,
color: '#52c41a',
},
{
name: '离线',
value: 3,
color: '#d9d9d9',
},
{
name: '告警',
value: 1,
color: '#faad14',
},
]}
angleField="value"
colorField="type"
color={['#52c41a', '#f5f5f5', '#faad14']}
radius={1}
innerRadius={0.7}
legend={false}
height={140}
/>
<div style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', textAlign: 'center' }}>
<div style={{ fontSize: 16, fontWeight: 800 }}>92.1%</div>

View File

@@ -18,6 +18,7 @@ import {
import { Line, Column, Pie, Area, DualAxes, Bar } from '@ant-design/charts';
import dayjs from 'dayjs';
import { ChevronRight } from 'lucide-react';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
@@ -73,6 +74,11 @@ const aiAnalysisData = [
{ type: '推荐清洗区块', value: 8, color: '#00B42A', icon: <ThunderboltOutlined /> },
{ type: '视频异常事件', value: 6, color: '#722ED1', icon: <EyeOutlined /> },
];
const aiPieData = aiAnalysisData.map(item => ({
name: item.type,
value: item.value,
color: item.color,
}));
const reportFileList = [
{ name: '2025年05月电站月报', status: '已生成' },
@@ -275,47 +281,29 @@ export default function ReportCenterPage() {
<Space size={4}><div style={{ width: 10, height: 1, borderTop: '1.5px dashed #165DFF' }}></div>预测发电 (MWh)</Space>
<Space size={4}><div style={{ width: 10, height: 1, borderTop: '1.5px solid #FF7D00' }}></div>PR (%)</Space>
</div>
<Line
<UniversalLineChart
data={monthlyPowerData}
xField="date"
yField={['generation', 'predicted', 'pr']}
seriesField="type"
color={['#52c41a', '#1890ff', '#fa8c16']}
lineStyle={(datum) => {
if (datum.type === 'pr') return { lineDash: [4, 4] };
return {};
}}
tooltip={{
formatter: (datum) => {
return {
name: datum.date,
data: [
{ name: '发电量(MWh)', value: datum.generation },
{ name: '预测发电(MWh)', value: datum.predicted },
{ name: 'PR(%)', value: datum.pr }
]
};
}
}}
legend={{
items: [
{ name: '发电量(MWh)', marker: { symbol: 'line', style: { stroke: '#52c41a' } } },
{ name: '预测发电(MWh)', marker: { symbol: 'line', style: { stroke: '#1890ff', lineDash: [4, 4] } } },
{ name: 'PR(%)', marker: { symbol: 'line', style: { stroke: '#fa8c16' } } },
]
}}
yAxis={[
xKey="date"
height={260}
series={[
{
label: { formatter: (v) => `${v}` },
name: '发电量',
key: 'generation',
name: '发电量(MWh)',
color: '#52c41a',
},
{
label: { formatter: (v) => `${v}%` },
name: 'PR',
position: 'right',
}
key: 'predicted',
name: '预测发电(MWh)',
color: '#1890ff',
dashed: true,
},
{
key: 'pr',
name: 'PR(%)',
color: '#fa8c16',
strokeWidth: 2,
},
]}
height={200}
/>
</Col>
<Col span={7}>
@@ -340,9 +328,14 @@ export default function ReportCenterPage() {
</Card>
{/* 第二排:三个图表 */}
<Row gutter={[12, 12]} style={{ marginTop: 16 }}>
<Row gutter={[12, 12]} style={{ marginTop: 16, }}>
<Col span={8}>
<Card bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '16px', }} title={<span style={{ fontSize: 14, fontWeight: 700 }}>发电与气象统计</span>}>
<Card
bordered={false}
style={{ ...cardStyle, height: "100%" }}
bodyStyle={{ padding: '16px' }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>发电与气象统计</span>}
>
<div style={{ fontSize: 10, color: '#86909C', marginBottom: 12 }}>
<Space size={8} wrap>
<Badge color="#165DFF" text="发电量 (MWh)" style={{ fontSize: 10 }} />
@@ -350,18 +343,26 @@ export default function ReportCenterPage() {
<Badge color="#FF7D00" text="温度 (℃)" style={{ fontSize: 10 }} />
</Space>
</div>
<Bar
<UniversalBarChart
data={powerMeteorologyData}
xField="date"
yField={['generation', 'irradiance', 'temp']}
color={['#1890ff', '#52c41a', '#fa8c16']}
legend={{ position: 'top' }}
height={180}
xKey="date"
height={200}
series={[
{ key: 'generation', name: '发电量', color: '#1890ff' },
{ key: 'irradiance', name: '辐照度', color: '#52c41a' },
{ key: 'temp', name: '温度', color: '#fa8c16' },
]}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '16px', }} title={<span style={{ fontSize: 14, fontWeight: 700 }}>工单与告警闭环分析</span>}>
<Card
bordered={false}
style={{ ...cardStyle, height: "100%" }}
bodyStyle={{ padding: '16px' }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>工单与告警闭环分析</span>}
>
<div style={{ fontSize: 10, color: '#86909C', marginBottom: 12 }}>
<Space size={8} wrap>
<Badge color="#165DFF" text="新增工单" style={{ fontSize: 10 }} />
@@ -369,57 +370,82 @@ export default function ReportCenterPage() {
<Badge color="#722ED1" text="闭环率 (%)" style={{ fontSize: 10 }} />
</Space>
</div>
<Bar
<UniversalBarChart
data={orderAlarmData}
xField="date"
yField={['newOrder', 'completed', 'alarmCount', 'closedRate']}
color={['#1890ff', '#52c41a', '#fa8c16', '#722ed1']}
legend={{ position: 'top' }}
height={180}
xKey="date"
height={200}
series={[
{ key: 'newOrder', name: '新增工单', color: '#1890ff' },
{ key: 'completed', name: '完成工单', color: '#52c41a' },
{ key: 'alarmCount', name: '告警数', color: '#fa8c16' },
{ key: 'closedRate', name: '闭环率', color: '#722ed1' },
]}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '16px', }} title={<span style={{ fontSize: 14, fontWeight: 700 }}>AI 分析成果统计</span>}>
<Row gutter={12} align="middle">
<Col span={11}>
<div style={{ position: 'relative', height: 160 }}>
<Pie
data={aiAnalysisData}
angleField="value"
colorField="type"
color={aiAnalysisData.map(d => d.color)}
radius={1}
innerRadius={0.7}
legend={false}
height={160}
autoFit
/>
<div style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', textAlign: 'center' }}>
<div style={{ fontSize: 10, color: '#86909C' }}>本月AI事件</div>
<div style={{ fontSize: 10, color: '#86909C' }}>总计</div>
<div style={{ fontSize: 20, fontWeight: 800, color: '#1D2129' }}>58</div>
<Card
bordered={false}
style={{ ...cardStyle, height: "100%" }}
bodyStyle={{ padding: '16px' }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>AI 分析成果统计</span>}
>
<div style={{ width: '100%', boxSizing: 'border-box' }}>
<UniversalPieChart
data={aiPieData}
width={220}
height={220}
innerRadius={40}
outerRadius={65}
style={{ padding: 0 }}
/>
<div style={{
display: 'flex',
flexDirection: 'column',
gap: 10,
paddingLeft: 8,
width: '100%',
boxSizing: 'border-box'
}}>
{aiAnalysisData.map((item, idx) => (
<div key={idx} style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
width: '100%',
flexWrap: 'wrap',
wordBreak: 'break-all',
whiteSpace: 'normal'
}}>
<Space size={6} style={{
fontSize: 11,
color: '#4E5969',
flex: 1,
minWidth: '60%',
display: 'flex',
alignItems: 'center',
flexWrap: 'wrap'
}}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: item.color, flexShrink: 0 }}></div>
<span style={{ wordBreak: 'break-all', whiteSpace: 'normal' }}>{item.type}</span>
</Space>
<span style={{
fontSize: 12,
fontWeight: 700,
whiteSpace: 'nowrap',
flexShrink: 0
}}>
{item.value} <Text type="secondary" style={{ fontSize: 10, fontWeight: 400 }}>个</Text>
</span>
</div>
</div>
</Col>
<Col span={13}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
{aiAnalysisData.map((item, idx) => (
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space size={6} style={{ fontSize: 11, color: '#4E5969' }}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: item.color }}></div>
{item.type}
</Space>
<span style={{ fontSize: 12, fontWeight: 700 }}>{item.value} <Text type="secondary" style={{ fontSize: 10, fontWeight: 400 }}>个</Text></span>
</div>
))}
</div>
</Col>
</Row>
))}
</div>
</div>
</Card>
</Col>
</Row>
{/* 订阅与分发 */}
<Card bordered={false} style={{ ...cardStyle, marginTop: 16 }} bodyStyle={{ padding: '20px' }} title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>订阅与分发</span>}>
<Row gutter={[16, 16]} wrap>

View File

@@ -30,6 +30,7 @@ import {
} from 'lucide-react';
// 导入工单接口
import { getWorkOrderApi, getWorkOrderDetailApi, updateWorkOrder, dispatchWorkOrder, completeWorkOrder } from '../api/workOrder';
import { UniversalLineChart } from '../components/recharts';
const { Option } = Select;
const { Search } = Input;
@@ -705,17 +706,24 @@ const WorkOrderPage = () => {
<Row gutter={12}>
<Col span={13}>
<div style={{ fontSize: 12, fontWeight: 700, color: '#1D2129', marginBottom: 12 }}>关联告警趋势 <Text type="secondary" style={{ fontSize: 11, fontWeight: 400 }}>(近 7 天)</Text></div>
<Line
<UniversalLineChart
data={alarmTrendData}
xField="date"
yField="value"
smooth
point={{ size: 3, shape: 'circle', style: { fill: '#165DFF', stroke: '#fff', lineWidth: 1 } }}
xKey="date"
height={130}
color="#165DFF"
padding={[10, 10, 20, 20]}
xAxis={{ label: { style: { fontSize: 9, fill: '#86909C' } } }}
yAxis={{ label: { style: { fontSize: 9, fill: '#86909C' } }, grid: { line: { style: { stroke: '#f0f0f0', lineDash: [3, 3] } } } }}
backgroundColor="transparent"
showLegend={false}
showTooltip={true}
showGrid={true}
smooth
dot
series={[
{
key: 'value',
name: '告警数量',
color: '#165DFF',
strokeWidth: 2,
},
]}
/>
</Col>
<Col span={11}>