浏览代码

Merge branch 'ETA_1.9.4' into debug

zwxi 8 月之前
父节点
当前提交
1292980b4c
共有 2 个文件被更改,包括 53 次插入1 次删除
  1. 29 1
      controllers/data_manage/chart_info.go
  2. 24 0
      services/data/chart_info.go

+ 29 - 1
controllers/data_manage/chart_info.go

@@ -1503,7 +1503,35 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 					}
 				}
 			} else if markerLines[i].Calculation == 3 {
-				// 区间分位
+				// 区间个数分位
+				markerLineValue := 0.0
+				for _, v := range edbList {
+					if v.IsAxis == 1 {
+						if chartInfo.ChartType == 2 && markerLines[i].EdbType == 0 {
+							//季节性图结构体不一样
+							dataList := make([]float64,0)
+							quarterDataList := v.DataList.(data_manage.QuarterDataList)
+							for _, quarterData := range quarterDataList[len(quarterDataList) - 1:] {
+								for _, vv := range quarterData.DataList {
+									dataList = append(dataList, vv.Value)
+								}
+
+								markerLineValue = data.PercentileAlgorithm(float64(markerLines[i].CalculationValue), dataList)
+								markerLines[i].Value = fmt.Sprintf("%.2f", markerLineValue)
+							}
+
+						} else {
+							dataList := v.DataList.([]*data_manage.EdbDataList)
+							floatList := make([]float64,0)
+							for _, dataItem := range dataList {
+								floatList = append(floatList, dataItem.Value)
+							}
+
+							markerLineValue = data.PercentileAlgorithm(float64(markerLines[i].CalculationValue), dataList)
+							markerLines[i].Value = fmt.Sprintf("%.2f", markerLineValue)
+						}
+					}
+				}
 			}
 		}
 

+ 24 - 0
services/data/chart_info.go

@@ -4093,3 +4093,27 @@ func SeasonChartData(dataList []*data_manage.ChartEdbInfoMapping, seasonExtraCon
 
 	return
 }
+
+// 计算百分位对应的值
+func PercentileAlgorithm(x float64, data []float64) float64 {
+	N := float64(len(data))
+	n := (x / 100) * (N - 1)
+
+	// 如果n是整数,则直接返回第n个数值
+	if n == float64(int(n)) {
+		return data[int(n)-1]
+	}
+
+	// 如果n是小数,执行插值
+	nInt := int(n)
+	e := n - float64(nInt)
+
+	// 取出相邻的两个数值
+	Sn := data[nInt-1]
+	Sn1 := data[nInt]
+
+	// 计算插值结果
+	y := Sn + e*(Sn1-Sn)
+
+	return y
+}