图表组件接入 显示成功

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

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