diff --git a/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue b/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue index 7f7709cb..3c2fdfe5 100644 --- a/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue +++ b/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue @@ -8,6 +8,12 @@ +
+ 风速来源 + + + +
{{ t('statAnalysis.search') }} @@ -29,17 +35,7 @@ :shortcuts="shortcuts" />
-
- 风速来源 - - - -
+
{{ t('statAnalysis.madeinfatory') }}
+
+ 显示曲线 + +
@@ -75,7 +75,8 @@ import * as echarts from 'echarts' import { getCutDecimalsValue } from '/@/views/backend/equipment/airBlower/utils' const { t } = useI18n() - +const AvgWindSpeedSwitch = ref(false) +const chartType = ref('scatter') // 默认散点图 const statAnalysisFatory = ref('') const statAnalysisFatoryList: any = ref([]) const statAnalysisSpeedSource = ref('AvgWindSpeed_10min') @@ -88,6 +89,28 @@ const statAnalysisSelectOptions: any = reactive({ deviceId: [], }) +const changeUpdateAvgWindSpeed = (val: any) => { + chartType.value = val ? 'line' : 'scatter' + updateChart() +} + +const seriesDataInit = ref([]) +const calculateData: any = ref([]) +const updateChart = () => { + const series = { + type: chartType.value, + data: chartType.value === 'scatter' ? seriesDataInit.value : calculateData.value, + name: '实际值', + symbolSize: 5, + symbol: 'circle', + } + option.series[0] = series + if (!option.legend.data.includes('实际值')) { + option.legend.data.push('实际值') + } + chart.value.setOption(option) +} + const getFormattedDate = (offset: number) => { const date = new Date() date.setDate(date.getDate() + offset) @@ -330,19 +353,12 @@ const statAnalysisOperate = () => { const seriesData = iGenPower.map((item: any, index: number) => { return [getCutDecimalsValue(iWindSpeed[index], 2), getCutDecimalsValue(item, 2)] }) - seriesData.sort((a: any, b: any) => { - return a[0] - b[0] - }) - - const series = { - type: 'scatter', - data: seriesData, - name: '实际值', - symbolSize: 5, - symbol: 'circle', - } - option.series.push(series) - option.legend.data.push('实际值') + // seriesData.sort((a: any, b: any) => { + // return a[0] - b[0] + // }) + seriesDataInit.value = seriesData + calculateData.value = calculateAverages(seriesDataInit.value) + updateChart() } } if (resData1.length) { @@ -360,9 +376,11 @@ const statAnalysisOperate = () => { option.series.push(series) option.legend.data.push('理论值') } + console.log('🚀 ~ .then ~ option.legend.data:', option.legend.data) chart.value.setOption(option) }) .catch((error) => { + console.log(error) isLoading.value = false ElMessage.warning(error) }) @@ -393,6 +411,34 @@ const statAnalysisExport = () => { document.body.removeChild(a) }) } + +const calculateAverages = (data: any) => { + let maxWindSpeed = Math.max(...data.map((item: any) => item[0])) + let interval = 5 // 每5m/s一个区间 + let result = [] + + for (let windSpeed = 0; windSpeed <= maxWindSpeed; windSpeed += interval) { + let sumPower = 0 + let count = 0 + + for (let i = 0; i < data.length; i++) { + let currentWindSpeed = data[i][0] + let currentPower = data[i][1] + + if (currentWindSpeed >= windSpeed && currentWindSpeed < windSpeed + interval) { + sumPower += currentPower + count++ + } + } + + if (count > 0) { + let averagePower = sumPower / count + result.push([windSpeed + interval, averagePower]) + } + } + + return result +}