From abe5631642bcab0062974889164685af48fc7808 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Thu, 14 May 2026 13:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E7=BB=84=E4=BB=B6=E5=B0=81?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/{recharts.tsx => recharts.jsx} | 65 +----- src/pages/AIAnalysis.tsx | 3 + src/pages/WorkOrder.tsx | 194 ++++++++++++++---- 3 files changed, 165 insertions(+), 97 deletions(-) rename src/components/{recharts.tsx => recharts.jsx} (75%) diff --git a/src/components/recharts.tsx b/src/components/recharts.jsx similarity index 75% rename from src/components/recharts.tsx rename to src/components/recharts.jsx index 8cb03ab..09af3f1 100644 --- a/src/components/recharts.tsx +++ b/src/components/recharts.jsx @@ -15,26 +15,6 @@ import { Bar, } from 'recharts'; -// ========================= -// 通用类型定义 -// ========================= - -export interface SeriesConfig { - key: string; - name: string; - color?: string; - strokeWidth?: number; -} - -export interface BaseChartProps { - width?: number | string; - height?: number; - showGrid?: boolean; - showLegend?: boolean; - showTooltip?: boolean; - backgroundColor?: string; - className?: string; -} // 默认颜色池 const DEFAULT_COLORS = [ @@ -48,21 +28,9 @@ const DEFAULT_COLORS = [ '#2f54eb', ]; -// ========================= -// 折线图组件 -// ========================= -export interface UniversalLineChartProps extends BaseChartProps { - data: Record[]; - xKey: string; - series: SeriesConfig[]; - smooth?: boolean; - dot?: boolean; - xAxisLabel?: string; - yAxisLabel?: string; -} -export const UniversalLineChart: React.FC = ({ +export const UniversalLineChart = ({ data, xKey, series, @@ -117,20 +85,9 @@ export const UniversalLineChart: React.FC = ({ ); }; -// ========================= -// 柱状图组件 -// ========================= -export interface UniversalBarChartProps extends BaseChartProps { - data: Record[]; - xKey: string; - series: SeriesConfig[]; - barSize?: number; - radius?: number | [number, number, number, number]; - stack?: boolean; -} -export const UniversalBarChart: React.FC = ({ +export const UniversalBarChart = ({ data, xKey, series, @@ -185,25 +142,9 @@ export const UniversalBarChart: React.FC = ({ ); }; -// ========================= -// 饼图组件 -// ========================= -export interface PieDataItem { - name: string; - value: number; - color?: string; -} -export interface UniversalPieChartProps extends BaseChartProps { - data: PieDataItem[]; - innerRadius?: number; - outerRadius?: number; - paddingAngle?: number; - showLabel?: boolean; -} - -export const UniversalPieChart: React.FC = ({ +export const UniversalPieChart = ({ data, width = '100%', height = 360, diff --git a/src/pages/AIAnalysis.tsx b/src/pages/AIAnalysis.tsx index 1b350de..172043a 100644 --- a/src/pages/AIAnalysis.tsx +++ b/src/pages/AIAnalysis.tsx @@ -11,6 +11,7 @@ import { SelectOutlined, FireOutlined, WarningOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; import { Line, Area } from '@ant-design/charts'; +import { UniversalBarChart, UniversalLineChart } from "../components/recharts" const { Title, Text } = Typography; @@ -115,6 +116,7 @@ const generationPerformanceConfig = { legend: { position: 'top' }, }; + export default function AIDiagnosisPage() { const cardStyle = { borderRadius: 12, @@ -140,6 +142,7 @@ export default function AIDiagnosisPage() { return (
+