Prechádzať zdrojové kódy

散点图单独处理,兼容PPT

cxmo 9 mesiacov pred
rodič
commit
2edf7c66a2

+ 8 - 0
src/views/dataEntry_manage/mixins/addOreditMixin.js

@@ -1035,6 +1035,14 @@ export default {
 		},
 		//新增/编辑保存图表时-判断用户有没有手动更改过上下限
 		getLimitInfo(){
+			//散点图单独处理
+			if(this.chartInfo.ChartType===5){
+				if(this.tableData[1]){
+					return Number(this.leftLimitData[0])===Number(this.tableData[1].MaxData)
+					&& Number(this.leftLimitData[1])===Number(this.tableData[1].MinData)
+				}
+				return false
+			}
 			const leftData = this.tableData.filter(i=>i.IsAxis===1).map(i=>[Number(i.MinData),Number(i.MaxData)])
 			const rightData = this.tableData.filter(i=>!i.IsAxis).map(i=>[Number(i.MinData),Number(i.MaxData)])
 			const rightTwoData = this.tableData.filter(i=>i.IsAxis===2).map(i=>[Number(i.MinData),Number(i.MaxData)])

+ 22 - 5
src/views/dataEntry_manage/mixins/chartPublic.js

@@ -1130,8 +1130,8 @@ export const chartSetMixin = {
         const useTableLimit = ['/predictEdb','/chartThemeSet'].includes(this.$route.path)
         let minLimit = 0,maxLimit = 0
         if(useTableLimit){
-            minLimit = Math.max(...real_data.map(_ => _.y));
-            maxLimit = Math.min(...real_data.map(_ => _.y));
+            minLimit = Math.min(...real_data.map(_ => _.y));
+            maxLimit = Math.max(...real_data.map(_ => _.y));
         }else{
             minLimit = this.leftLimitData[1]||0
             maxLimit = this.leftLimitData[0]||0
@@ -1170,8 +1170,8 @@ export const chartSetMixin = {
         },
         opposite: false,
         reversed: IsOrder,
-        min: Number(newval[1].MinData),
-        max: Number(newval[1].MaxData),
+        min: Number(minLimit),
+        max: Number(maxLimit),
         tickWidth: 1,
         plotBands: this.setAxisPlotAreas(1),
         plotLines: this.setAxisPlotLines(1)
@@ -2657,9 +2657,16 @@ export const chartSetMixin = {
 				});
 			}
 		},
-    
+        /* ----自定义上下限相关--- */
         /* 计算y轴上下限 */
         calcYAxislimit(tableData=[]) {
+            //散点图单独处理
+            if(this.chartInfo.ChartType===5){
+                if(tableData[1]){
+                    this.leftLimitData = [tableData[1].MaxData,tableData[1].MinData]
+                }
+                return 
+            }
             //分组
             const leftData = tableData.filter(i => i.IsAxis === 1).map(i => [Number(i.MinData), Number(i.MaxData)])
             const rightData = tableData.filter(i => !i.IsAxis).map(i => [Number(i.MinData), Number(i.MaxData)])
@@ -2743,6 +2750,15 @@ export const chartSetMixin = {
             }
         },
         checkLimit(tableData=[]){
+            //散点图单独处理
+            if(this.chartInfo.ChartType===5){
+                if(tableData[1]){
+                    if(Number(this.leftLimitData[0])===0&&Number(this.leftLimitData[1])===0){
+                        this.leftLimitData = [tableData[1].MaxData,tableData[1].MinData]
+                    }
+                }
+                return 
+            }
             //若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
             if(Number(this.leftLimitData[0])===0&&Number(this.leftLimitData[1])===0){
                 const leftData = tableData.filter(i=>i.IsAxis===1).map(i=>[Number(i.MinData),Number(i.MaxData)])
@@ -2772,5 +2788,6 @@ export const chartSetMixin = {
                 }
             }
         },
+        /*-------------------- */
 	}
 }

+ 165 - 9
src/views/ppt_manage/mixins/mixins.js

@@ -31,6 +31,9 @@ const basicYAxis = {
 export default {
   data() {
     return {
+      leftLimitData:[0,0],//左轴上下限
+      rightLimitData:[0,0],//右轴上下限
+      rightTwoLimitData:[0,0],//右二轴上下限
       bgList:[
         {image_url:require('@/assets/img/ppt_m/bg3.jpg')},
         {image_url:require('@/assets/img/ppt_m/bg4.jpg')},
@@ -115,6 +118,15 @@ export default {
       chartData.forEach((item, index) => {
         //轴位置值相同的下标
         let sameSideIndex = chartData.findIndex(i => i.IsAxis === item.IsAxis);
+        //获取对应轴的上下限
+        let minLimit = 0,maxLimit = 0
+        const limitMap = {
+            0:this.rightLimitData||[],
+            1:this.leftLimitData||[],
+            2:this.rightTwoLimitData||[]
+        }
+        minLimit = limitMap[item.IsAxis][1]||0
+        maxLimit = limitMap[item.IsAxis][0]||0
         //y轴
         const textZh = item.ConvertUnit||item.Unit
         const textEn = item.ConvertEnUnit||item.UnitEn||item.ConvertUnit||item.Unit
@@ -147,8 +159,8 @@ export default {
           },
           opposite: [0,2].includes(item.IsAxis),
           reversed: item.IsOrder,
-          min: Number(item.MinData),
-          max: Number(item.MaxData),
+          min: Number(minLimit),
+          max: Number(maxLimit),
           tickWidth: 1,
           visible: sameSideIndex === index,
           plotBands: this.setAxisPlotAreas(item.IsAxis),
@@ -278,6 +290,16 @@ export default {
         ? -1
         : this.dataList.findIndex((item) => item.IsAxis===2);
 
+         //获取对应轴的上下限
+         let minLimit = 0,maxLimit = 0
+         const limitMap = {
+             0:this.rightLimitData||[],
+             1:this.leftLimitData||[],
+             2:this.rightTwoLimitData||[]
+         }
+         minLimit = limitMap[item.IsAxis][1]||0
+         maxLimit = limitMap[item.IsAxis][0]||0
+
         //y轴
         let yItem = {
           ...basicYAxis,
@@ -308,8 +330,8 @@ export default {
           },
           opposite: [0,2].includes(item.IsAxis),
           reversed: item.IsOrder,
-          min: Number(chartData[sameSideIndex].MinData),
-          max: Number(chartData[sameSideIndex].MaxData),
+          min: Number(minLimit),
+          max: Number(maxLimit),
           tickWidth: sameSideIndex !== index ? 0 : 1,
           visible: serie_yIndex === index && sameSideIndex ===index,
           plotBands: this.setAxisPlotAreas(item.IsAxis),
@@ -402,6 +424,10 @@ export default {
       let seasonYdata = [],
         seasonData = []
 
+        //获取对应轴的上下限
+        let minLimit = 0,maxLimit = 0
+        minLimit = this.leftLimitData[1]||0
+        maxLimit = this.leftLimitData[0]||0
       //数据列
       for (let j of chartDataHandle) {
           //预测指标配置
@@ -455,8 +481,8 @@ export default {
           textAlign: 'left',
           reserveSpace: false
         },
-        max: Number(chartData.MaxData),
-        min: Number(chartData.MinData),
+        max: Number(maxLimit),
+        min: Number(minLimit),
         plotBands: this.setAxisPlotAreas(1),
         plotLines: this.setAxisPlotLines(1)
       }];
@@ -560,6 +586,10 @@ export default {
       }
 
       const { IsOrder,ChartColor,MaxData,MinData } = chartData[0];
+      //获取对应轴的上下限
+      let minLimit = 0,maxLimit = 0
+      minLimit = this.leftLimitData[1]||0
+      maxLimit = this.leftLimitData[0]||0
       //y轴
       const textYZh = chartData[1].ConvertUnit||chartData[1].Unit
       const textYEn = chartData[1].ConvertEnUnit||chartData[1].UnitEn||chartData[1].ConvertUnit||chartData[1].Unit
@@ -587,8 +617,8 @@ export default {
         },
         opposite: false,
         reversed: IsOrder,
-        min: Number(chartData[1].MinData),
-        max: Number(chartData[1].MaxData),
+        min: Number(minLimit),
+        max: Number(maxLimit),
         tickWidth: 1,
         tickLength: 5,
         lineWidth: 1,
@@ -1812,6 +1842,132 @@ export default {
       })
 
       return plotBands
-    }
+    },
+    /* ----自定义上下限相关--- */
+    setLimitData(tableData=[]){
+        const {
+            //左右轴极值字段 
+            LeftMin=0,LeftMax=0,
+            RightMin=0,RightMax=0,
+            Right2Min=0,Right2Max=0,
+            MinMaxSave
+        } = this.chartInfo
+        if(MinMaxSave){
+            this.leftLimitData = [Number(LeftMax),Number(LeftMin)]
+            this.rightLimitData = [Number(RightMax),Number(RightMin)]
+            this.rightTwoLimitData = [Number(Right2Max),Number(Right2Min)]
+            //若用户修改过,则检测轴的上下限是否为空,若为空,则需要计算对应轴的上下限
+            this.checkLimit(tableData)
+        }else{
+            this.calcYAxislimit(tableData)
+        }
+    },
+    checkLimit(tableData=[]){
+        //散点图单独处理
+        if(this.chartInfo.ChartType===5){
+            if(tableData[1]){
+                if(Number(this.leftLimitData[0])===0&&Number(this.leftLimitData[1])===0){
+                    this.leftLimitData = [tableData[1].MaxData,tableData[1].MinData]
+                }
+            }
+            return 
+        }
+        //若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
+        if(Number(this.leftLimitData[0])===0&&Number(this.leftLimitData[1])===0){
+            const leftData = tableData.filter(i=>i.IsAxis===1).map(i=>[Number(i.MinData),Number(i.MaxData)])
+            if(leftData.length){
+                const {Max,Min} = this.calcLimit(leftData.flat())
+                this.leftLimitData = [Max,Min]
+            }else{
+                this.leftLimitData = [0,0]
+            }
+        }
+        if(Number(this.rightLimitData[0])===0&&Number(this.rightLimitData[1])===0){
+            const rightData = tableData.filter(i => !i.IsAxis).map(i=>[Number(i.MinData),Number(i.MaxData)])
+            if(rightData.length){
+                const {Max,Min} = this.calcLimit(rightData.flat())
+                this.rightLimitData = [Max,Min]
+            }else{
+                this.rightLimitData = [0,0]
+            }
+        }
+        if(Number(this.rightTwoLimitData[0])===0&&Number(this.rightTwoLimitData[1])===0){
+            const rightTwoData = tableData.filter(i=>i.IsAxis===2).map(i=>[Number(i.MinData),Number(i.MaxData)])
+            if(rightTwoData.length){
+                const {Max,Min} = this.calcLimit(rightTwoData.flat())
+                this.rightTwoLimitData = [Max,Min]
+            }else{
+                this.rightTwoLimitData = [0,0]
+            }
+        }
+    },
+    /* 计算y轴上下限 */
+    calcYAxislimit(tableData=[]) {
+        //散点图单独处理
+        if(this.chartInfo.ChartType===5){
+            if(tableData[1]){
+                this.leftLimitData = [tableData[1].MaxData,tableData[1].MinData]
+            }
+            return 
+        }
+        //分组
+        const leftData = tableData.filter(i => i.IsAxis === 1).map(i => [Number(i.MinData), Number(i.MaxData)])
+        const rightData = tableData.filter(i => !i.IsAxis).map(i => [Number(i.MinData), Number(i.MaxData)])
+        const rightTwoData = tableData.filter(i => i.IsAxis === 2).map(i => [Number(i.MinData), Number(i.MaxData)])
+        //计算最大最小值
+        if (leftData.length) {
+            const {
+                Max,
+                Min
+            } = this.calcLimit(leftData.flat())
+            this.leftLimitData = [Max, Min]
+        } else {
+            this.leftIndex = -1
+            this.leftLimitData = [0, 0]
+        }
+        if (rightData.length) {
+            const {
+                Max,
+                Min
+            } = this.calcLimit(rightData.flat())
+            this.rightLimitData = [Max, Min]
+        } else {
+            this.rightIndex = -1
+            this.rightLimitData = [0, 0]
+        }
+        if (rightTwoData.length) {
+            const {
+                Max,
+                Min
+            } = this.calcLimit(rightTwoData.flat())
+            this.rightTwoLimitData = [Max, Min]
+        } else {
+            this.rightTwoIndex = -1
+            this.rightTwoLimitData = [0, 0]
+        }
+        console.table([{
+                'y轴': '左轴',
+                '最大值': this.leftLimitData[0],
+                '最小值': this.leftLimitData[1]
+            },
+            {
+                'y轴': '右轴',
+                '最大值': this.rightLimitData[0],
+                '最小值': this.rightLimitData[1]
+            },
+            {
+                'y轴': '右二轴',
+                '最大值': this.rightTwoLimitData[0],
+                '最小值': this.rightTwoLimitData[1]
+            }
+        ])
+    },
+    calcLimit(arr) {
+        return {
+            Max: Math.max(...arr),
+            Min: Math.min(...arr)
+        }
+    },
+    /*-------------------- */
   },
 };

+ 2 - 0
src/views/ppt_manage/mixins/pptMixins.js

@@ -211,6 +211,8 @@ export default {
         this.setDefaultSourceFrom();
         
         this.dataList = Data.EdbInfoList;
+        //初始化上下限
+        this.setLimitData(this.dataList)
         //柱形图独立数据
         this.chartInfo.ChartType === 7 && this.initBarData(res.Data);
         //截面散点图