From e53971d9779889889ff8153c391361606d640ab4 Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期二, 22 四月 2025 16:10:11 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- src/components/echarts/DataComparison.vue | 131 +++++++++++++++++++++++++++---------------- 1 files changed, 83 insertions(+), 48 deletions(-) diff --git a/src/components/echarts/DataComparison.vue b/src/components/echarts/DataComparison.vue index 19d65e7..fd62924 100644 --- a/src/components/echarts/DataComparison.vue +++ b/src/components/echarts/DataComparison.vue @@ -163,7 +163,7 @@ :legend="legend2" :lineColors="lineColors" :series="echartsSeries2" - :tooltip="tooltip" + :tooltip="tooltip1" :xAxis="xAxis" :yAxis="yAxis2" style="height: 40vh;"></Echarts> @@ -190,6 +190,7 @@ <script> import Echarts from "./echarts.vue"; +import {getRawSupplierCompare} from "@/api/statisticalCharts/dataAnalysis"; export default { name: "DataComparison", @@ -277,6 +278,20 @@ type: 'shadow' } }, + tooltip1: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + }, + formatter: (params) => { + // params 鏄竴涓暟缁勶紝鍖呭惈褰撳墠榧犳爣鎮仠鐨勬墍鏈夌郴鍒楃殑鏁版嵁 + return params.map(param => { + const value = param.value; // 鑾峰彇褰撳墠鏁版嵁鐐圭殑鍊� + const name = param.seriesName; // 鑾峰彇绯诲垪鍚嶇О + return `${name}: ${Math.round(value)}%`; // 鏍煎紡鍖栦负鐧惧垎姣斿舰寮� + }).join('<br>'); // 姣忎釜绯诲垪鍗犱竴琛� + } + }, xAxis: [{ type: 'category', data: ['1', '2', '3', '4', '5'] @@ -351,7 +366,10 @@ yAxis2: [{ type: 'value', min: 0, - max: 1, + max: 100, + axisLabel: { + formatter: '{value}%' // 鍦ㄦ瘡涓埢搴﹀�煎悗娣诲姞鐧惧垎姣旂鍙� + } }], echartsSeries2: [ { @@ -360,7 +378,7 @@ label: { show: true, position: 'top', - formatter: (params) => Math.round(params.value * 1000) / 10 + '%' + formatter: (params) => params.value + '%' }, data: [], }, @@ -370,7 +388,7 @@ label: { show: true, position: 'top', - formatter: (params) => Math.round(params.value * 1000) / 10 + '%' + formatter: (params) => params.value + '%' }, data: [], } @@ -389,43 +407,65 @@ }, // 鏂规硶闆嗗悎 methods: { - getInfo () { - this.localData = this.comparisonData.localData === null ? ['', '', '', '', '','','', '', ''] : this.comparisonData.localData - this.localData = this.localData.map((number, index) => index === 7 ? `${Math.round(number * 100)}%` : number) - this.echartsSeries3[0].data = this.localData.slice(0, 5) - this.localULC = this.comparisonData.localULC - this.localLCL = this.comparisonData.localLCL - this.localAverage = this.comparisonData.localAverage - this.localRange = this.comparisonData.localRange + getInfo() { + const { localData, localULC, localLCL, localAverage, localRange } = this.comparisonData; + // 鍒濆鍖� localData锛岀‘淇濇湁榛樿鍊� + this.localData = localData === null + ? ['', '', '', '', '', '', '', '', ''] + : localData.map((number, index) => index === 7 ? `${Math.round(number * 100)}%` : number); + // 鏇存柊鍥捐〃鏁版嵁 + this.echartsSeries3[0].data = this.localData.slice(0, 5); + this.localULC = localULC; + this.localLCL = localLCL; + this.localAverage = localAverage; + this.localRange = localRange; }, - getInfo1 () { - this.echartsSeries1[0].data = [] - this.supplierData = this.comparisonData1.supplierData === null ? ['', '', '', '', '','','', '', ''] : this.comparisonData1.supplierData - this.localData = this.comparisonData1.localData === null ? ['', '', '', '', '','','', '', ''] : this.comparisonData1.localData - this.localData = this.localData.map((number, index) => index === 7 ? `${Math.round(number * 100)}%` : number) - this.echartsSeries3[0].data = this.localData.slice(0, 5) - this.echartsSeries[0].data = this.supplierData - this.echartsSeries[1].data = this.localData - this.absoluteDeviation = this.comparisonData1.absoluteDeviation === null ? ['', '', '', '', '','','', '', ''] : this.comparisonData1.absoluteDeviation - this.echartsSeries2[1].data = this.absoluteDeviation - this.absoluteDeviation = this.absoluteDeviation.map(number => `${Math.round(number * 100)}%`) // 缁濆鍋忓樊鐧惧垎姣旇浆鎹� - this.average = this.comparisonData1.average === null ? ['', '', '', '', '','','', '', ''] : this.comparisonData1.average - this.echartsSeries2[0].data = this.average - this.average = this.average.map(number => `${Math.round(number * 100)}%`) // 骞冲潎鍊肩櫨鍒嗘瘮杞崲 - this.supplierULC = this.comparisonData1.supplierULC === null ? ['', '', '', '', ''] : this.comparisonData1.supplierULC - this.echartsSeries1[0].data.push(this.supplierULC[0]) // 娴嬮噺鏁版嵁鏍囧噯宸姣旀煴鐘跺浘鏁版嵁 - this.supplierLCL = this.comparisonData1.supplierLCL === null ? ['', '', '', '', ''] : this.comparisonData1.supplierLCL - this.echartsSeries1[1].data.push(this.supplierLCL[0]) // 娴嬮噺鏁版嵁鏍囧噯宸姣旀煴鐘跺浘鏁版嵁 - this.supplierAverage = this.comparisonData1.supplierAverage === null ? ['', '', '', '', ''] : this.comparisonData1.supplierAverage - this.echartsSeries1[2].data.push(this.supplierAverage[0]) // 娴嬮噺鏁版嵁鏍囧噯宸姣旀煴鐘跺浘鏁版嵁 - this.supplierRange = this.comparisonData1.supplierRange === null ? ['', '', '', '', ''] : this.comparisonData1.supplierRange - this.localULC = this.comparisonData1.localULC - this.echartsSeries1[0].data.push(this.localULC[0]) // 娴嬮噺鏁版嵁鏍囧噯宸姣旀煴鐘跺浘鏁版嵁 - this.localLCL = this.comparisonData1.localLCL - this.echartsSeries1[1].data.push(this.localLCL[0]) // 娴嬮噺鏁版嵁鏍囧噯宸姣旀煴鐘跺浘鏁版嵁 - this.localAverage = this.comparisonData1.localAverage - this.echartsSeries1[2].data.push(this.localAverage[0]) // 娴嬮噺鏁版嵁鏍囧噯宸姣旀煴鐘跺浘鏁版嵁 - this.localRange = this.comparisonData1.localRange + getInfo1() { + const { + supplierData, + localData, + absoluteDeviation, + average, + supplierULC, + supplierLCL, + supplierAverage, + supplierRange, + localULC, + localLCL, + localAverage, + localRange, + } = this.comparisonData1; + // 杈呭姪鍑芥暟锛氬鐞嗙┖鏁版嵁骞惰浆鎹㈢櫨鍒嗘瘮 + const processPercentageData = (data, defaultValue = ['', '', '', '', '', '', '', '', '']) => + data === null ? defaultValue : data.map((number, index) => index === 7 ? `${Math.round(number * 100)}%` : number); + // 杈呭姪鍑芥暟锛氬鐞嗙┖鏁板�煎瀷鏁版嵁 + const processNumericData = (data, defaultValue = ['', '', '', '', '']) => + data === null ? defaultValue : data; + // 鍒濆鍖栨暟鎹� + this.supplierData = processPercentageData(supplierData); + this.localData = processPercentageData(localData); + this.absoluteDeviation = processPercentageData(absoluteDeviation).map(number => `${Math.round(number * 100)}%`); + this.average = processPercentageData(average).map(number => `${Math.round(number * 100)}%`); + // 鏇存柊鍥捐〃鏁版嵁 + this.echartsSeries1[0].data = []; + this.echartsSeries3[0].data = this.localData.slice(0, 5); + this.echartsSeries[0].data = this.supplierData; + this.echartsSeries[1].data = this.localData; + this.echartsSeries2[1].data = this.comparisonData1.absoluteDeviation.map(value => value * 100); + this.echartsSeries2[0].data = this.comparisonData1.average.map(value => value * 100); + // 澶勭悊渚涘簲鍟嗗拰鏈湴鐨勬爣鍑嗗樊瀵规瘮鏁版嵁 + this.supplierULC = processNumericData(supplierULC); + this.supplierLCL = processNumericData(supplierLCL); + this.supplierAverage = processNumericData(supplierAverage); + this.supplierRange = processNumericData(supplierRange); + this.localULC = processNumericData(localULC); + this.localLCL = processNumericData(localLCL); + this.localAverage = processNumericData(localAverage); + this.localRange = processNumericData(localRange); + // 鏇存柊娴嬮噺鏁版嵁鏍囧噯宸姣旀煴鐘跺浘鏁版嵁 + this.echartsSeries1[0].data.push(this.supplierULC[0], this.localULC[0]); + this.echartsSeries1[1].data.push(this.supplierLCL[0], this.localLCL[0]); + this.echartsSeries1[2].data.push(this.supplierAverage[0], this.localAverage[0]); }, submitForm () { this.$refs['supplierForm'].validate((valid) => { @@ -435,12 +475,7 @@ itemNames: this.selectRow.itemNames, supplierDataList: Object.values(this.supplierForm) } - this.$axios.post(this.$api.dataAnalysis.getRawSupplierCompare, params, { - headers: { - 'Content-Type': 'application/json' - }, - noQs: true - }).then(res => { + getRawSupplierCompare(params).then(res => { this.comparisonData1 = res.data this.getInfo1() }) @@ -459,8 +494,8 @@ <style scoped> .title { - height: 60px; - line-height: 60px; + height: 40px; + line-height: 40px; } .container { width: calc(100% - 20px); -- Gitblit v1.9.3