图表组件接入 显示成功

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

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