|
@@ -56,6 +56,7 @@
|
|
|
import { ref, onMounted, nextTick } from 'vue';
|
|
import { ref, onMounted, nextTick } from 'vue';
|
|
|
import * as echarts from 'echarts';
|
|
import * as echarts from 'echarts';
|
|
|
import axios from 'axios';
|
|
import axios from 'axios';
|
|
|
|
|
+import {api8000} from '@/utils/request'
|
|
|
|
|
|
|
|
// 图表容器 & 实例
|
|
// 图表容器 & 实例
|
|
|
const initialCdChart = ref(null); // 初始Cd图表
|
|
const initialCdChart = ref(null); // 初始Cd图表
|
|
@@ -89,35 +90,35 @@ const fieldConfig = {
|
|
|
]
|
|
]
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 数据请求
|
|
|
|
|
|
|
+// 数据请求 - 增强错误处理和调试
|
|
|
const fetchData = async () => {
|
|
const fetchData = async () => {
|
|
|
try {
|
|
try {
|
|
|
- const apiUrl = 'http://localhost:8000/api/vector/stats/FluxCd_input_data';
|
|
|
|
|
- const response = await axios.get(apiUrl);
|
|
|
|
|
- const rawData = response.data.features
|
|
|
|
|
- ? response.data.features.map(f => f.properties)
|
|
|
|
|
- : response.data.data;
|
|
|
|
|
- return rawData;
|
|
|
|
|
|
|
+ isLoading.value = true;
|
|
|
|
|
+ const apiUrl = '/api/vector/stats/FluxCd_input_data';
|
|
|
|
|
+ console.log('正在请求数据:', apiUrl);
|
|
|
|
|
+
|
|
|
|
|
+ const response = await api8000.get(apiUrl);
|
|
|
|
|
+ console.log('API响应:', response);
|
|
|
|
|
+
|
|
|
|
|
+ // 调试:输出响应结构
|
|
|
|
|
+ console.log('响应数据:', response.data);
|
|
|
|
|
+
|
|
|
|
|
+ // 处理不同的响应格式
|
|
|
|
|
+ let processedData;
|
|
|
|
|
+ processedData = response.data.data;
|
|
|
|
|
+
|
|
|
|
|
+ if (!processedData) {
|
|
|
|
|
+ throw new Error('无法解析API返回的数据结构');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ console.log('处理后的数据:', processedData);
|
|
|
|
|
+ return processedData;
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
- throw new Error('数据加载失败: ' + err.message);
|
|
|
|
|
|
|
+ console.error('数据请求失败:', err);
|
|
|
|
|
+ throw new Error(`数据加载失败: ${err.message || '网络或服务器错误'}`);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 分位数计算(QUARTILE.INC)
|
|
|
|
|
-const calculatePercentile = (sortedArray, percentile) => {
|
|
|
|
|
- const n = sortedArray.length;
|
|
|
|
|
- if (n === 0) return null;
|
|
|
|
|
- if (percentile <= 0) return sortedArray[0];
|
|
|
|
|
- if (percentile >= 100) return sortedArray[n - 1];
|
|
|
|
|
-
|
|
|
|
|
- const index = (n - 1) * (percentile / 100);
|
|
|
|
|
- const lowerIndex = Math.floor(index);
|
|
|
|
|
- const upperIndex = lowerIndex + 1;
|
|
|
|
|
- const fraction = index - lowerIndex;
|
|
|
|
|
-
|
|
|
|
|
- if (upperIndex >= n) return sortedArray[lowerIndex];
|
|
|
|
|
- return sortedArray[lowerIndex] + fraction * (sortedArray[upperIndex] - sortedArray[lowerIndex]);
|
|
|
|
|
-};
|
|
|
|
|
|
|
|
|
|
// 计算单个字段的统计量
|
|
// 计算单个字段的统计量
|
|
|
const calculateFieldStats = (statsData, fieldKey, fieldName) => {
|
|
const calculateFieldStats = (statsData, fieldKey, fieldName) => {
|