From 3a23adbf7ca67ee299d1f7dcb2a1a4a12da4077a Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Mon, 20 Apr 2026 14:55:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=99=AF=E5=8C=BA=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- zlt-web/react-web-next/src/pages/Welcome.tsx | 77 ++++++++++---------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index cb905680..898a6104 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,6 @@ zlt-web/yingyan/public/cesium/ # 忽略 dist 目录(所有层级) dist/ # 忽略 dist.zip 文件 -dist.zip +zlt-web/react-web-next/dist.zip + +zlt-web/yingyan/dist.zip diff --git a/zlt-web/react-web-next/src/pages/Welcome.tsx b/zlt-web/react-web-next/src/pages/Welcome.tsx index af110182..dfeac825 100644 --- a/zlt-web/react-web-next/src/pages/Welcome.tsx +++ b/zlt-web/react-web-next/src/pages/Welcome.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState, useMemo } from 'react'; import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid, Slider, InputNumber, Tooltip } from 'antd'; import { ReloadOutlined } from '@ant-design/icons'; import { Line, Pie, Bar } from '@ant-design/plots'; @@ -270,23 +270,20 @@ const Welcome: React.FC = () => { // 计算总订单数用于百分比显示 const totalScenicOrders = scenicOrderData.reduce((sum, item) => sum + item.orderCount, 0); - // 最多同时可见 5 条,通过容器滚动查看全部 - const MAX_SCENIC_BARS = 6; - const ROW_HEIGHT = 35; - const chartFullHeight = Math.max(((Array.isArray(scenicOrderData) ? scenicOrderData.length : 0) * ROW_HEIGHT), MAX_SCENIC_BARS * ROW_HEIGHT); + // 每个条形的高度,容器固定高度显示8条,超出滚动 + const MAX_VISIBLE_BARS = 8; + const BAR_HEIGHT = 50; // 每个条形的高度 + const chartFullHeight = Math.max((Array.isArray(scenicOrderData) ? scenicOrderData.length : 0) * BAR_HEIGHT, 400); + const containerHeight = MAX_VISIBLE_BARS * BAR_HEIGHT; // 固定容器高度400px // 景区订单数量横向条形图配置 - 景区名称在Y轴(左侧),订单数量横向展示 - const scenicOrderConfig: any = { + const scenicOrderConfig: any = useMemo(() => ({ data: scenicOrderData, - xField: 'tourismName', // 这里反直觉:xField是分类(显示为Y轴) - yField: 'orderCount', // yField是数值(显示为横向长度) - autoFit: true, + xField: 'orderCount', // 横向数值轴 + yField: 'tourismName', // 纵向分类轴(景区名称) + autoFit: false, // 关闭自动适应,使用固定高度 height: chartFullHeight, - // 关键:转置坐标系,使横向条形图 - coordinate: { - transpose: true, - }, - // 使用绿色渐变,根据数值大小 + // 使用渐变色,根据数值大小 color: ({ orderCount }: any) => { const maxCount = Math.max(...scenicOrderData.map(d => d.orderCount), 1); const ratio = orderCount / maxCount; @@ -297,64 +294,57 @@ const Welcome: React.FC = () => { return '#B7EB8F'; // 很浅绿 }, label: { - position: 'right', // 标签显示在条形右侧外部 - offset: 8, + position: 'right', + offset: 10, content: (item: any) => { - // 订单数为0时不显示标签,避免与景区名称重叠 if (item.orderCount === 0) return ''; return `${item.orderCount}单`; }, style: { - fill: '#666', - fontSize: 12, - fontWeight: 500, - textAlign: 'left', + fill: '#595959', + fontSize: 13, + fontWeight: 600, }, }, xAxis: { - title: { - text: '订单数量', - style: { - fontSize: 14, - fontWeight: 500, - }, - }, grid: { line: { style: { - stroke: '#E8E8E8', + stroke: '#F0F0F0', lineWidth: 1, - lineDash: [3, 3], + lineDash: [4, 4], }, }, }, label: { - formatter: (val: string) => `${Number(val)}单`, style: { fontSize: 12, + fill: '#8C8C8C', }, }, }, yAxis: { label: { style: { - fontSize: isMobile ? 11 : 13, + fontSize: 13, fill: '#262626', + fontWeight: 500, }, autoEllipsis: true, autoRotate: false, }, }, barStyle: { - radius: [0, 4, 4, 0], // 右侧圆角 + radius: [0, 6, 6, 0], // 右侧圆角 }, animation: { appear: { animation: 'scale-in-x', - duration: 800, + duration: 600, + easing: 'ease-out', }, }, - }; + }), [scenicOrderData, chartFullHeight]); // 饼图配置 const chartStats = stat?.chartStats || {}; @@ -951,8 +941,21 @@ const Welcome: React.FC = () => { {/* 景区订单数量统计:单行展示 */} - -
+ +