Browse Source

Merge branch 'ETA_1.9.4' into debug

zwxi 8 months ago
parent
commit
e1407a0147
1 changed files with 15 additions and 6 deletions
  1. 15 6
      services/data/chart_info.go

+ 15 - 6
services/data/chart_info.go

@@ -4122,6 +4122,7 @@ func MarkerLineCalculate(markerLine data_manage.MarkersLine, dataList interface{
 	if markerLine.Calculation == 1 {
 		// 区间均值
 		averge := 0.0
+		length := 0
 		// 计算左轴
 		if chartInfo.ChartType == 2 && markerLine.EdbType == 0 {
 			//季节性图结构体不一样
@@ -4158,12 +4159,13 @@ func MarkerLineCalculate(markerLine data_manage.MarkersLine, dataList interface{
 						}
 						if vv.DataTime >= startDate && vv.DataTime <= endDate {
 							averge += vv.Value
+							length +=1
 						}
 					} else {
 						averge += vv.Value
 					}
 				}
-				averge = averge / float64(len(quarterData.DataList))
+				averge = averge / float64(length)
 				value = fmt.Sprintf("%.2f", averge)
 			}
 		} else {
@@ -4199,18 +4201,21 @@ func MarkerLineCalculate(markerLine data_manage.MarkersLine, dataList interface{
 					}
 					if dataItem.DataTime >= startDate && dataItem.DataTime <= endDate {
 						averge += dataItem.Value
+						length += 1
 					}
 				} else {
 					averge += dataItem.Value
+					length += 1
 				}
 			}
-			averge = averge / float64(len(dataList))
+			averge = averge / float64(length)
 
 			value = fmt.Sprintf("%.2f", averge)
 		}
 	} else if markerLine.Calculation == 2 {
 		// 区间均值加N倍标准差
 		averge := 0.0
+		length := 0
 		// 计算左轴
 		if chartInfo.ChartType == 2 && markerLine.EdbType == 0 {
 			//季节性图结构体不一样
@@ -4247,15 +4252,17 @@ func MarkerLineCalculate(markerLine data_manage.MarkersLine, dataList interface{
 							endDate, err = HandleDateChange(endDate, markerLine.StartDate.Conf)
 						}
 						if vv.DataTime >= startDate && vv.DataTime <= endDate {
-							dataList = append(faloatList, vv.Value)
+							faloatList = append(faloatList, vv.Value)
 							averge += vv.Value
+							length += 1
 						}
 					} else {
-						dataList = append(faloatList, vv.Value)
+						faloatList = append(faloatList, vv.Value)
 						averge += vv.Value
+						length += 1
 					}
 				}
-				averge = averge / float64(len(quarterData.DataList))
+				averge = averge / float64(length)
 				stdev := utils.CalculateStandardDeviation(faloatList)
 				stdev, _ = decimal.NewFromFloat(stdev).Round(4).Float64()
 
@@ -4297,13 +4304,15 @@ func MarkerLineCalculate(markerLine data_manage.MarkersLine, dataList interface{
 					if dataItem.DataTime >= startDate && dataItem.DataTime <= endDate {
 						floatList = append(floatList, dataItem.Value)
 						averge += dataItem.Value
+						length += 1
 					}
 				} else {
 					floatList = append(floatList, dataItem.Value)
 					averge += dataItem.Value
+					length += 1
 				}
 			}
-			averge = averge / float64(len(dataList))
+			averge = averge / float64(length)
 
 			stdev := utils.CalculateStandardDeviation(floatList)
 			stdev, _ = decimal.NewFromFloat(stdev).Round(4).Float64()