图表组件接入 显示成功

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

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