Roc 2 年之前
父节点
当前提交
d1d540d1ad
共有 1 个文件被更改,包括 12 次插入14 次删除
  1. 12 14
      services/data/future_good/chart_info.go

+ 12 - 14
services/data/future_good/chart_info.go

@@ -765,13 +765,13 @@ func handleResultData(regionType string, yDataList []models.YData, futureGoodEdb
 	newYDataList = yDataList
 
 	if regionType == `国内` {
-		for i := range futureGoodEdbInfoList {
+		for i := 1; i < 12; i++ {
 			if i > maxIndex {
 				break
 			}
 			xDataList = append(xDataList, models.XData{
-				Name:   fmt.Sprint("M+", i+1),
-				NameEn: fmt.Sprint("M+", i+1),
+				Name:   fmt.Sprint("M+", i),
+				NameEn: fmt.Sprint("M+", i),
 			})
 		}
 		return
@@ -876,30 +876,28 @@ func handleResultData(regionType string, yDataList []models.YData, futureGoodEdb
 		}
 	}
 
-	maxI := len(xDataList)
+	maxI := 0
 	for _, yData := range newYDataList {
 		lenEdb := len(yData.XEdbInfoIdList)
-		for i := lenEdb - 1; i >= 0; i-- {
-			if yData.XEdbInfoIdList[i] == 0 || utils.InArrayByInt(yData.NoDataEdbList, yData.XEdbInfoIdList[i]) {
-				maxI = i
-				if maxI > i {
+		for i := 0; i < lenEdb; i++ {
+			if yData.XEdbInfoIdList[i] != 0 && !utils.InArrayByInt(yData.NoDataEdbList, yData.XEdbInfoIdList[i]) {
+				if maxI < i {
 					maxI = i
 				}
-			} else {
-				break
 			}
 		}
 	}
 
 	xDataList = xDataList[0:maxI]
 	for yIndex, yData := range newYDataList {
-		if len(yData.XEdbInfoIdList) > maxI {
-			newYDataList[yIndex].XEdbInfoIdList = yData.XEdbInfoIdList[0:maxI]
+		if len(yData.XEdbInfoIdList) > maxI+1 {
+			newYDataList[yIndex].XEdbInfoIdList = yData.XEdbInfoIdList[0 : maxI+1]
 		}
-		if len(yData.Value) > maxI {
-			newYDataList[yIndex].Value = yData.Value[0:maxI]
+		if len(yData.Value) > maxI+1 {
+			newYDataList[yIndex].Value = yData.Value[0 : maxI+1]
 		}
 	}
+
 	return
 }