数据分析平台 测试图表调整
This commit is contained in:
parent
21912904c6
commit
988d303aca
@ -339,6 +339,16 @@ func Histogram(req *request.Histogram) ([]*model.Histogram, error) {
|
||||
}
|
||||
fTHistogram[index].StandardDeviation = math.Sqrt(standardDeviation / fTHistogram[index].N)
|
||||
|
||||
if !req.MergeChart {
|
||||
x = []string{}
|
||||
minDecimal, _ = decimal.NewFromString(fTHistogram[index].Min)
|
||||
maxDecimal, _ = decimal.NewFromString(fTHistogram[index].Max)
|
||||
interval = maxDecimal.Sub(minDecimal).Div(decimal.NewFromInt(50))
|
||||
for i := 0; i < 51; i++ {
|
||||
xPoint := minDecimal.Add(interval.Mul(decimal.NewFromInt(int64(i)))).String()
|
||||
x = append(x, xPoint)
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(x); i++ {
|
||||
if i == len(x)-1 {
|
||||
xFloat, _ := strconv.ParseFloat(x[i], 64)
|
||||
@ -410,6 +420,17 @@ func Histogram(req *request.Histogram) ([]*model.Histogram, error) {
|
||||
}
|
||||
}
|
||||
fTHistogram[index].StandardDeviation = math.Sqrt(standardDeviation / fTHistogram[index].N)
|
||||
|
||||
if !req.MergeChart {
|
||||
x = []string{}
|
||||
minDecimal, _ = decimal.NewFromString(fTHistogram[index].Min)
|
||||
maxDecimal, _ = decimal.NewFromString(fTHistogram[index].Max)
|
||||
interval = maxDecimal.Sub(minDecimal).Div(decimal.NewFromInt(50))
|
||||
for i := 0; i < 51; i++ {
|
||||
xPoint := minDecimal.Add(interval.Mul(decimal.NewFromInt(int64(i)))).String()
|
||||
x = append(x, xPoint)
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(x); i++ {
|
||||
if i == len(x)-1 {
|
||||
xFloat, _ := strconv.ParseFloat(x[i], 64)
|
||||
|
@ -372,33 +372,33 @@ func ExportHistogram(req *request.Histogram) string {
|
||||
selectionInfo[k] = []float64{v[0], v[1], v[2], v[3], v[2] / v[3], 0, 0}
|
||||
selectionHistogramX[k] = []string{}
|
||||
minDecimal := decimal.NewFromFloat(v[0])
|
||||
if minDecimal.Abs().LessThan(decimal.NewFromInt(1)) {
|
||||
if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
minDecimal = minDecimal.RoundUp(0)
|
||||
} else {
|
||||
minDecimal = minDecimal.RoundDown(0)
|
||||
}
|
||||
} else {
|
||||
if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
minDecimal = minDecimal.RoundDown(1)
|
||||
} else {
|
||||
minDecimal = minDecimal.RoundUp(1)
|
||||
}
|
||||
}
|
||||
//if minDecimal.Abs().LessThan(decimal.NewFromInt(1)) {
|
||||
// if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// minDecimal = minDecimal.RoundUp(0)
|
||||
// } else {
|
||||
// minDecimal = minDecimal.RoundDown(0)
|
||||
// }
|
||||
//} else {
|
||||
// if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// minDecimal = minDecimal.RoundDown(1)
|
||||
// } else {
|
||||
// minDecimal = minDecimal.RoundUp(1)
|
||||
// }
|
||||
//}
|
||||
maxDecimal := decimal.NewFromFloat(v[1])
|
||||
if maxDecimal.Abs().LessThan(decimal.NewFromInt(1)) {
|
||||
if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
maxDecimal = maxDecimal.RoundDown(0)
|
||||
} else {
|
||||
maxDecimal = maxDecimal.RoundUp(0)
|
||||
}
|
||||
} else {
|
||||
if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
maxDecimal = maxDecimal.RoundDown(1)
|
||||
} else {
|
||||
maxDecimal = maxDecimal.RoundUp(1)
|
||||
}
|
||||
}
|
||||
//if maxDecimal.Abs().LessThan(decimal.NewFromInt(1)) {
|
||||
// if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// maxDecimal = maxDecimal.RoundDown(0)
|
||||
// } else {
|
||||
// maxDecimal = maxDecimal.RoundUp(0)
|
||||
// }
|
||||
//} else {
|
||||
// if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// maxDecimal = maxDecimal.RoundDown(1)
|
||||
// } else {
|
||||
// maxDecimal = maxDecimal.RoundUp(1)
|
||||
// }
|
||||
//}
|
||||
interval := maxDecimal.Sub(minDecimal).Div(decimal.NewFromInt(20))
|
||||
for i := 0; i < 21; i++ {
|
||||
xPoint := minDecimal.Add(interval.Mul(decimal.NewFromInt(int64(i)))).String()
|
||||
@ -720,17 +720,17 @@ func ExportHistogram(req *request.Histogram) string {
|
||||
if req.SpliteSite {
|
||||
selectionHistogramX[group+"_"+k] = []string{}
|
||||
minDecimal := decimal.NewFromFloat(v[0])
|
||||
if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
minDecimal = minDecimal.RoundUp(0)
|
||||
} else {
|
||||
minDecimal = minDecimal.RoundDown(0)
|
||||
}
|
||||
//if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// minDecimal = minDecimal.RoundUp(0)
|
||||
//} else {
|
||||
// minDecimal = minDecimal.RoundDown(0)
|
||||
//}
|
||||
maxDecimal := decimal.NewFromFloat(v[1])
|
||||
if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
maxDecimal = maxDecimal.RoundDown(0)
|
||||
} else {
|
||||
maxDecimal = maxDecimal.RoundUp(0)
|
||||
}
|
||||
//if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// maxDecimal = maxDecimal.RoundDown(0)
|
||||
//} else {
|
||||
// maxDecimal = maxDecimal.RoundUp(0)
|
||||
//}
|
||||
interval := maxDecimal.Sub(minDecimal).Div(decimal.NewFromInt(20))
|
||||
for i := 0; i < 21; i++ {
|
||||
xPoint := minDecimal.Add(interval.Mul(decimal.NewFromInt(int64(i)))).String()
|
||||
@ -743,17 +743,17 @@ func ExportHistogram(req *request.Histogram) string {
|
||||
if !req.SpliteSite {
|
||||
selectionHistogramX[group+"_"+k] = []string{}
|
||||
minDecimal := decimal.NewFromFloat(v[0])
|
||||
if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
minDecimal = minDecimal.RoundUp(0)
|
||||
} else {
|
||||
minDecimal = minDecimal.RoundDown(0)
|
||||
}
|
||||
//if minDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// minDecimal = minDecimal.RoundUp(0)
|
||||
//} else {
|
||||
// minDecimal = minDecimal.RoundDown(0)
|
||||
//}
|
||||
maxDecimal := decimal.NewFromFloat(v[1])
|
||||
if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
maxDecimal = maxDecimal.RoundDown(0)
|
||||
} else {
|
||||
maxDecimal = maxDecimal.RoundUp(0)
|
||||
}
|
||||
//if maxDecimal.LessThan(decimal.NewFromInt(0)) {
|
||||
// maxDecimal = maxDecimal.RoundDown(0)
|
||||
//} else {
|
||||
// maxDecimal = maxDecimal.RoundUp(0)
|
||||
//}
|
||||
|
||||
interval := maxDecimal.Sub(minDecimal).Div(decimal.NewFromInt(20))
|
||||
for i := 0; i < 21; i++ {
|
||||
@ -848,6 +848,7 @@ func ExportHistogram(req *request.Histogram) string {
|
||||
rowIndex, colIndex := 2, 1
|
||||
histogramFile.NewSheet(group)
|
||||
selectionValueMap := make(map[string][]int)
|
||||
|
||||
for k, v := range selectionHistogramX {
|
||||
sheetX := []interface{}{k}
|
||||
for _, x := range v {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test_data
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/shopspring/decimal"
|
||||
"gorm.io/gorm"
|
||||
"sort"
|
||||
@ -1016,7 +1017,7 @@ func FTList(r *request.FTList) ([]*model.FTShowList, int64) {
|
||||
siteMap := make(map[string]model.ReportListSites)
|
||||
for _, report := range reports {
|
||||
firstPassQuantity, _ := decimal.NewFromString(report.FirstPassQuantity)
|
||||
listFirstPassQuantity, _ := decimal.NewFromString(ftShowList.PassQuantity)
|
||||
listFirstPassQuantity, _ := decimal.NewFromString(ftShowList.FirstPassQuantity)
|
||||
testQuantity, _ := decimal.NewFromString(report.TestQuantity)
|
||||
passQuantity, _ := decimal.NewFromString(report.PassQuantity)
|
||||
listTestQuantity, _ := decimal.NewFromString(ftShowList.TestQuantity)
|
||||
@ -1359,9 +1360,25 @@ func FTList(r *request.FTList) ([]*model.FTShowList, int64) {
|
||||
sort.Slice(softBinFail, func(i, j int) bool {
|
||||
return softBinFail[i].Quantity > softBinFail[j].Quantity
|
||||
})
|
||||
var m map[string]interface{}
|
||||
for _, v := range finalReports {
|
||||
if v.SubBatch == report.SubBatch {
|
||||
marshal, _ := json.Marshal(&v)
|
||||
_ = json.Unmarshal(marshal, &m)
|
||||
}
|
||||
}
|
||||
for hardBin, hardBinQuantity := range hardBinFailMap {
|
||||
hardBinQuantityDecimal := decimal.NewFromFloat(hardBinQuantity)
|
||||
reportSoftBinQuantityDecimal := decimal.NewFromFloat(reportHardBinFailMap[hardBin])
|
||||
var reportHardBinQuantityDecimal decimal.Decimal
|
||||
var reportQuantity float64
|
||||
if _, ok := m["bin"+hardBin]; ok {
|
||||
reportHardBinQuantityDecimal, _ = decimal.NewFromString(m["bin"+hardBin].(string))
|
||||
reportQuantity, _ = strconv.ParseFloat(m["bin"+hardBin].(string), 64)
|
||||
} else {
|
||||
reportHardBinQuantityDecimal = decimal.NewFromFloat(0)
|
||||
reportQuantity = 0.0
|
||||
}
|
||||
//reportHardBinQuantityDecimal := decimal.NewFromFloat(reportHardBinFailMap[hardBin])
|
||||
var proportion, reportProportion string
|
||||
if !subBatchTestQuantityDecimal.IsZero() {
|
||||
proportion = hardBinQuantityDecimal.Div(subBatchTestQuantityDecimal).Round(4).
|
||||
@ -1370,7 +1387,7 @@ func FTList(r *request.FTList) ([]*model.FTShowList, int64) {
|
||||
proportion = "0%"
|
||||
}
|
||||
if !subBatchTestQuantityDecimal.IsZero() {
|
||||
reportProportion = reportSoftBinQuantityDecimal.Div(subBatchTestQuantityDecimal).Round(4).
|
||||
reportProportion = reportHardBinQuantityDecimal.Div(subBatchTestQuantityDecimal).Round(4).
|
||||
Mul(decimal.NewFromInt(100)).String() + "%"
|
||||
} else {
|
||||
reportProportion = "0%"
|
||||
@ -1379,7 +1396,7 @@ func FTList(r *request.FTList) ([]*model.FTShowList, int64) {
|
||||
Bin: hardBin,
|
||||
Quantity: hardBinQuantity,
|
||||
Proportion: proportion,
|
||||
ReportQuantity: reportHardBinFailMap[hardBin],
|
||||
ReportQuantity: reportQuantity,
|
||||
ReportProportion: reportProportion,
|
||||
})
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ type Histogram struct {
|
||||
SpliteSite bool `json:"splite_site"`
|
||||
XMax string `json:"x_max"`
|
||||
XMin string `json:"x_min"`
|
||||
MergeChart bool `json:"merge_chart"`
|
||||
}
|
||||
|
||||
// Scatter 散点图
|
||||
|
Loading…
Reference in New Issue
Block a user