From 9d71e24e7982f6915e5f832512925bee9b245f35 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 20 八月 2024 16:13:26 +0800
Subject: [PATCH] #

---
 src/pages/right/components/stat-charts.jsx |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/pages/right/components/stat-charts.jsx b/src/pages/right/components/stat-charts.jsx
index 38497f6..e540a62 100644
--- a/src/pages/right/components/stat-charts.jsx
+++ b/src/pages/right/components/stat-charts.jsx
@@ -1,10 +1,32 @@
-import React from 'react';
+import { useEffect, useState } from 'react';
 import ReactECharts from 'echarts-for-react';
 import * as echarts from 'echarts/core';
 
+const getLatestDateArr = () => {
+  let dates = [];
+
+  for (let i = 0; i < 5; i++) {
+    let d = new Date();
+    d.setDate(d.getDate() - i);
+    let month = (d.getMonth() + 1).toString().padStart(2, '0'); // getMonth() 杩斿洖鍊间负 0锛堜竴鏈堬級 鍒� 11锛堝崄浜屾湀锛� 
+    let day = d.getDate().toString().padStart(2, '0');
+    dates.unshift(`${month}/${day}`);
+  }
+
+  return dates;
+}
+
 const StatCharts = () => {
+  const [xdata, setXdata] = useState([]);
+
+  useEffect(() => {
+    const dates = getLatestDateArr();
+    setXdata(dates);
+  }, []);
+
+
   let chartData = {
-    xdata: ['01/01', '01/02', '01/03', '01/04', '01/05'],
+    xdata: xdata,
     currentYearList: [10, 20, 30, 40, 50],
     lastYearList: [20, 10, 30, 40, 20],
     rateDataOne: [10, 40, 20, 30, 50],
@@ -226,7 +248,7 @@
   return (
     <>
       <div>
-        <ReactECharts style={{ height: '250px' }} option={option} />
+        <ReactECharts style={{ height: '270px' }} option={option} />
       </div>
     </>
   );

--
Gitblit v1.9.1