浏览代码

chart增加loading

xujunjie 2 年之前
父节点
当前提交
5904c2852e
共有 1 个文件被更改,包括 15 次插入13 次删除
  1. 15 13
      src/pages/Mobile/DataMeter/Chart.js

+ 15 - 13
src/pages/Mobile/DataMeter/Chart.js

@@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from 'react';
 import { connect } from 'dva';
 import moment from 'moment';
 import style from './Chart.less';
-import { Card, Empty } from 'antd';
+import { Card, Empty, Spin } from 'antd';
 import { getOptions } from '@/components/ChartUtils/utils';
 const dataCache = {};
 
@@ -41,12 +41,12 @@ function DataCenter(props) {
     }
   }, [projectId]);
 
-  useEffect(() => {
-    const chartWindow = iframeRef.current?.contentWindow;
-    console.log(chartOptions);
-    if (!chartWindow || !chartOptions) return;
-    renderChart();
-  }, [chartOptions]);
+  // useEffect(() => {
+  //   const chartWindow = iframeRef.current?.contentWindow;
+  //   console.log(chartOptions);
+  //   if (!chartWindow || !chartOptions) return;
+  //   renderChart();
+  // }, [chartOptions]);
 
   useEffect(() => {
     if (chartConfigList && chartConfigList.length > 0) {
@@ -99,12 +99,14 @@ function DataCenter(props) {
         )}
       </Card>
       <Card title="图表" bodyStyle={{ paddingBottom: 0 }}>
-        <iframe
-          ref={iframeRef}
-          style={{ width: '100%', height: 'calc(50vh - 80px)', border: 'none' }}
-          onLoad={renderChart}
-          srcDoc={chartOptions?.template?.Content}
-        ></iframe>
+        <Spin spinning={loading}>
+          <iframe
+            ref={iframeRef}
+            style={{ width: '100%', height: 'calc(50vh - 80px)', border: 'none' }}
+            onLoad={renderChart}
+            srcDoc={chartOptions?.template?.Content}
+          ></iframe>
+        </Spin>
       </Card>
     </div>
   );