|
|
@ -1,4 +1,4 @@ |
|
|
package customChartes |
|
|
package customChartesing |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"appPlatform/api/version1/customerform" |
|
|
"appPlatform/api/version1/customerform" |
|
|
@ -33,88 +33,641 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c |
|
|
tayTime := time.Now().Unix() |
|
|
tayTime := time.Now().Unix() |
|
|
charData.XAxis.Types = "category" |
|
|
charData.XAxis.Types = "category" |
|
|
charData.YAxis.Types = "value" |
|
|
charData.YAxis.Types = "value" |
|
|
|
|
|
|
|
|
|
|
|
searchTime := c.JieXiSearchTime() |
|
|
|
|
|
|
|
|
|
|
|
fmt.Printf("时间字段--->%v\n\n", x.TimeType) |
|
|
|
|
|
|
|
|
switch x.TimeType { |
|
|
switch x.TimeType { |
|
|
case "year": |
|
|
case "year": |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 16) |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 16) |
|
|
charData.XAxis.Data = []string{yearVal} |
|
|
if len(searchTime) > 0 { |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "all", 12) |
|
|
charData.XAxis.Data = searchTime |
|
|
|
|
|
} else { |
|
|
|
|
|
charData.XAxis.Data = []string{yearVal} |
|
|
|
|
|
} |
|
|
|
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "all", 12, charData.XAxis.Data) |
|
|
case "month": |
|
|
case "month": |
|
|
var timeList []string |
|
|
var timeList []string |
|
|
tayTime := int(time.Now().Month()) |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 16) |
|
|
for i := 1; i <= tayTime; i++ { |
|
|
tayTimeing := int(time.Now().Month()) |
|
|
timeList = append(timeList, fmt.Sprintf("%v月", i)) |
|
|
for i := 1; i <= tayTimeing; i++ { |
|
|
|
|
|
timeList = append(timeList, fmt.Sprintf("%v-%v", yearVal, i)) |
|
|
|
|
|
} |
|
|
|
|
|
if len(searchTime) > 0 { |
|
|
|
|
|
charData.XAxis.Data = searchTime |
|
|
|
|
|
} else { |
|
|
|
|
|
charData.XAxis.Data = timeList |
|
|
} |
|
|
} |
|
|
charData.XAxis.Data = timeList |
|
|
|
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "month", tayTime) |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "month", tayTimeing, charData.XAxis.Data) |
|
|
case "day": |
|
|
case "day": |
|
|
// tayTime := int(time.Now().Day())
|
|
|
tayTimeing := int(time.Now().Day()) |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 4) |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 15) |
|
|
charData.XAxis.Data = []string{yearVal} |
|
|
fmt.Printf("时间字段-1-->%v\n\n", tayTimeing) |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "day", 1) |
|
|
var timeList []string |
|
|
|
|
|
for i := 1; i <= tayTimeing; i++ { |
|
|
|
|
|
timeList = append(timeList, fmt.Sprintf("%v-%v", yearVal, i)) |
|
|
|
|
|
} |
|
|
|
|
|
fmt.Printf("时间字段-1-->%v-->%v\n\n", len(searchTime), searchTime) |
|
|
|
|
|
if len(searchTime) > 0 { |
|
|
|
|
|
charData.XAxis.Data = searchTime |
|
|
|
|
|
} else { |
|
|
|
|
|
charData.XAxis.Data = timeList |
|
|
|
|
|
} |
|
|
|
|
|
charData.NewCalculateNumericalValues(y, val, x.Field, chartType, "day", tayTimeing, charData.XAxis.Data) |
|
|
|
|
|
|
|
|
case "hour": |
|
|
case "hour": |
|
|
var timeList []string |
|
|
var timeList []string |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 7) |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 7) |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 4) |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 14) |
|
|
hourInt, _ := strconv.Atoi(yearVal) |
|
|
hourInt, _ := strconv.Atoi(yearVal) |
|
|
for i := 1; i <= hourInt; i++ { |
|
|
for i := 1; i <= hourInt; i++ { |
|
|
timeList = append(timeList, fmt.Sprintf("%v 时", ymd, i)) |
|
|
timeList = append(timeList, fmt.Sprintf("%v %v", ymd, i)) |
|
|
|
|
|
} |
|
|
|
|
|
if len(searchTime) > 0 { |
|
|
|
|
|
charData.XAxis.Data = searchTime |
|
|
|
|
|
} else { |
|
|
|
|
|
charData.XAxis.Data = timeList |
|
|
} |
|
|
} |
|
|
charData.XAxis.Data = timeList |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "hour", hourInt, charData.XAxis.Data) |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "hour", hourInt) |
|
|
|
|
|
case "minute": |
|
|
case "minute": |
|
|
var timeList []string |
|
|
var timeList []string |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 9) |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 9) |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 3) |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 13) |
|
|
hourInt, _ := strconv.Atoi(yearVal) |
|
|
hourInt, _ := strconv.Atoi(yearVal) |
|
|
for i := 1; i <= hourInt; i++ { |
|
|
for i := 1; i <= hourInt; i++ { |
|
|
timeList = append(timeList, fmt.Sprintf("%v", ymd, i)) |
|
|
timeList = append(timeList, fmt.Sprintf("%v %v", ymd, i)) |
|
|
} |
|
|
} |
|
|
charData.XAxis.Data = timeList |
|
|
if len(searchTime) > 0 { |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "minute", hourInt) |
|
|
charData.XAxis.Data = searchTime |
|
|
|
|
|
} else { |
|
|
|
|
|
charData.XAxis.Data = timeList |
|
|
|
|
|
} |
|
|
|
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "minute", hourInt, charData.XAxis.Data) |
|
|
case "second": |
|
|
case "second": |
|
|
var timeList []string |
|
|
var timeList []string |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 10) |
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 10) |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 2) |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 12) |
|
|
hourInt, _ := strconv.Atoi(yearVal) |
|
|
hourInt, _ := strconv.Atoi(yearVal) |
|
|
for i := 1; i <= hourInt; i++ { |
|
|
for i := 1; i <= hourInt; i++ { |
|
|
timeList = append(timeList, fmt.Sprintf("%v", ymd, i)) |
|
|
timeList = append(timeList, fmt.Sprintf("%v %v", ymd, i)) |
|
|
} |
|
|
} |
|
|
charData.XAxis.Data = timeList |
|
|
if len(searchTime) > 0 { |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "second", hourInt) |
|
|
charData.XAxis.Data = searchTime |
|
|
|
|
|
} else { |
|
|
|
|
|
charData.XAxis.Data = timeList |
|
|
|
|
|
} |
|
|
|
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "second", hourInt, charData.XAxis.Data) |
|
|
default: |
|
|
default: |
|
|
var timeList []string |
|
|
var timeList []string |
|
|
|
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 15) |
|
|
tayTime := int(time.Now().Month()) |
|
|
tayTime := int(time.Now().Month()) |
|
|
for i := 1; i <= tayTime; i++ { |
|
|
for i := 1; i <= tayTime; i++ { |
|
|
timeList = append(timeList, fmt.Sprintf("%v月", i)) |
|
|
timeList = append(timeList, fmt.Sprintf("%v-%v", yearVal, i)) |
|
|
|
|
|
} |
|
|
|
|
|
if len(searchTime) > 0 { |
|
|
|
|
|
charData.XAxis.Data = searchTime |
|
|
|
|
|
} else { |
|
|
|
|
|
charData.XAxis.Data = timeList |
|
|
} |
|
|
} |
|
|
charData.XAxis.Data = timeList |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "month", tayTime, charData.XAxis.Data) |
|
|
charData.CalculateNumericalValues(y, val, x.Field, chartType, "month", tayTime) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
// xAxis := c.JieXiSearchTime()
|
|
|
|
|
|
// if len(xAxis) > 0 {
|
|
|
|
|
|
// charData.XAxis.Data = xAxis
|
|
|
|
|
|
// }
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 计算数值
|
|
|
// 计算数值
|
|
|
// 1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值
|
|
|
// 1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值
|
|
|
// 当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数;
|
|
|
// 当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数;
|
|
|
func (b *BarDataInfo) CalculateNumericalValues(y []YAxisInfo, val interface{}, xField, chartType string, types string, lenght int) { |
|
|
func (b *BarDataInfo) NewCalculateNumericalValues(y []YAxisInfo, val interface{}, xField, chartType string, types string, lenght int, timeAry []string) { |
|
|
|
|
|
|
|
|
for _, v := range y { |
|
|
for _, v := range y { |
|
|
var seriesInfo SeriesList |
|
|
var seriesInfo SeriesList |
|
|
seriesInfo.Name = v.OldTitle |
|
|
seriesInfo.Name = v.OldTitle |
|
|
seriesInfo.Types = chartType |
|
|
seriesInfo.Types = chartType |
|
|
switch v.Method { |
|
|
switch v.Method { |
|
|
case 2: |
|
|
case 2: |
|
|
seriesInfo.AverageValue(xField, v.Field, types, val, v.Format, lenght) |
|
|
seriesInfo.NewAverageValue(xField, v.Field, types, val, v.Format, timeAry) |
|
|
case 3: |
|
|
case 3: |
|
|
seriesInfo.StatisticalQuantity(xField, v.Field, types, val, v.Format, lenght) |
|
|
seriesInfo.NewStatisticalQuantity(xField, v.Field, types, val, v.Format, timeAry) |
|
|
case 4: |
|
|
case 4: |
|
|
seriesInfo.RemoveDuplicateCounts(xField, v.Field, types, val, v.Format, lenght) |
|
|
seriesInfo.NewRemoveDuplicateCounts(xField, v.Field, types, val, v.Format, timeAry) |
|
|
case 5: |
|
|
case 5: |
|
|
seriesInfo.maxData(xField, v.Field, types, val, v.Format, lenght) |
|
|
seriesInfo.NewmaxData(xField, v.Field, types, val, v.Format, timeAry) |
|
|
case 6: |
|
|
case 6: |
|
|
seriesInfo.minData(xField, v.Field, types, val, v.Format, lenght) |
|
|
seriesInfo.NewminData(xField, v.Field, types, val, v.Format, timeAry) |
|
|
default: |
|
|
default: |
|
|
seriesInfo.sumData(xField, v.Field, types, val, v.Format, lenght) |
|
|
seriesInfo.NewsumData(xField, v.Field, types, val, v.Format, timeAry) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !publicmethod.IsInTrue[string](v.OldTitle, b.Legend.Data) { |
|
|
|
|
|
b.Legend.Data = append(b.Legend.Data, v.OldTitle) |
|
|
|
|
|
} |
|
|
|
|
|
// if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
|
|
|
|
// for mi, mv := range yVal {
|
|
|
|
|
|
// fmt.Printf("\n\nyVal =====> %v =====> %v\n\n", mi, mv)
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
b.Series = append(b.Series, seriesInfo) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* |
|
|
|
|
|
@ 作者: 秦东 |
|
|
|
|
|
@ 时间: 2025-07-25 14:51:33 |
|
|
|
|
|
@ 功能: |
|
|
|
|
|
|
|
|
|
|
|
#xField X轴信息 |
|
|
|
|
|
#yField Y轴信息 |
|
|
|
|
|
#types 时间信息 |
|
|
|
|
|
#format 值约束 |
|
|
|
|
|
#timeAry 时间数组 |
|
|
|
|
|
*/ |
|
|
|
|
|
func (s *SeriesList) NewAverageValue(xField, yField, types string, val interface{}, format int, timeAry []string) { |
|
|
|
|
|
var monthAry []interface{} |
|
|
|
|
|
for _, v := range timeAry { |
|
|
|
|
|
switch types { |
|
|
|
|
|
case "year": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "month": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
|
|
|
|
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
|
|
|
|
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
|
|
|
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
|
|
|
|
|
monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime.AllTime, val, xField, yField, format)) |
|
|
|
|
|
case "day": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "hour": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "minute": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "second": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
s.Data = monthAry |
|
|
|
|
|
} |
|
|
|
|
|
func (s *SeriesList) QuPingjunSumData(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
|
|
|
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk { |
|
|
|
|
|
var sumVal float64 |
|
|
|
|
|
jibuqi := 0 |
|
|
|
|
|
for _, mv := range yVal { |
|
|
|
|
|
if yVal, isOk := mv[yField]; isOk { |
|
|
|
|
|
if xVal, isOk := mv[xField]; isOk { |
|
|
|
|
|
pageTime, _ := publicmethod.StringToInt64(xVal) |
|
|
|
|
|
if publicmethod.GetIntLength(pageTime) >= 13 { |
|
|
|
|
|
startTime = startTime * 1000 |
|
|
|
|
|
endTime = endTime * 1000 |
|
|
|
|
|
} |
|
|
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
|
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
sumVal = sumVal + minVal |
|
|
|
|
|
jibuqi++ |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if jibuqi > 0 { |
|
|
|
|
|
avgVal := sumVal / float64(jibuqi) |
|
|
|
|
|
jieguo = publicmethod.DataChuli(avgVal, format) |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
jieguo = publicmethod.DataChuli(sumVal, format) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* |
|
|
|
|
|
@ 作者: 秦东 |
|
|
|
|
|
@ 时间: 2025-07-25 14:51:33 |
|
|
|
|
|
@ 功能: |
|
|
|
|
|
|
|
|
|
|
|
#xField X轴信息 |
|
|
|
|
|
#yField Y轴信息 |
|
|
|
|
|
#types 时间信息 |
|
|
|
|
|
#format 值约束 |
|
|
|
|
|
#timeAry 时间数组 |
|
|
|
|
|
*/ |
|
|
|
|
|
func (s *SeriesList) NewStatisticalQuantity(xField, yField, types string, val interface{}, format int, timeAry []string) { |
|
|
|
|
|
var monthAry []interface{} |
|
|
|
|
|
for _, v := range timeAry { |
|
|
|
|
|
switch types { |
|
|
|
|
|
case "year": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "month": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
|
|
|
|
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
|
|
|
|
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
|
|
|
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
|
|
|
|
|
monthAry = append(monthAry, s.QuJishuData(startTime, endTime.AllTime, val, xField, yField, format)) |
|
|
|
|
|
case "day": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "hour": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "minute": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "second": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
s.Data = monthAry |
|
|
|
|
|
} |
|
|
|
|
|
func (s *SeriesList) QuJishuData(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
|
|
|
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk { |
|
|
|
|
|
var valAry []float64 |
|
|
|
|
|
for _, mv := range yVal { |
|
|
|
|
|
if yVal, isOk := mv[yField]; isOk { |
|
|
|
|
|
if xVal, isOk := mv[xField]; isOk { |
|
|
|
|
|
pageTime, _ := publicmethod.StringToInt64(xVal) |
|
|
|
|
|
if publicmethod.GetIntLength(pageTime) >= 13 { |
|
|
|
|
|
startTime = startTime * 1000 |
|
|
|
|
|
endTime = endTime * 1000 |
|
|
|
|
|
} |
|
|
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
|
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
|
|
|
|
valAry = append(valAry, minVal) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
jieguo = len(valAry) |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* |
|
|
|
|
|
@ 作者: 秦东 |
|
|
|
|
|
@ 时间: 2025-07-25 14:51:33 |
|
|
|
|
|
@ 功能: |
|
|
|
|
|
|
|
|
|
|
|
#xField X轴信息 |
|
|
|
|
|
#yField Y轴信息 |
|
|
|
|
|
#types 时间信息 |
|
|
|
|
|
#format 值约束 |
|
|
|
|
|
#timeAry 时间数组 |
|
|
|
|
|
*/ |
|
|
|
|
|
func (s *SeriesList) NewRemoveDuplicateCounts(xField, yField, types string, val interface{}, format int, timeAry []string) { |
|
|
|
|
|
var monthAry []interface{} |
|
|
|
|
|
for _, v := range timeAry { |
|
|
|
|
|
switch types { |
|
|
|
|
|
case "year": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "month": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
|
|
|
|
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
|
|
|
|
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
|
|
|
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
|
|
|
|
|
monthAry = append(monthAry, s.QuChongData(startTime, endTime.AllTime, val, xField, yField, format)) |
|
|
|
|
|
case "day": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "hour": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "minute": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "second": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
s.Data = monthAry |
|
|
|
|
|
} |
|
|
|
|
|
func (s *SeriesList) QuChongData(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
|
|
|
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk { |
|
|
|
|
|
var valAry []float64 |
|
|
|
|
|
for _, mv := range yVal { |
|
|
|
|
|
if yVal, isOk := mv[yField]; isOk { |
|
|
|
|
|
if xVal, isOk := mv[xField]; isOk { |
|
|
|
|
|
pageTime, _ := publicmethod.StringToInt64(xVal) |
|
|
|
|
|
if publicmethod.GetIntLength(pageTime) >= 13 { |
|
|
|
|
|
startTime = startTime * 1000 |
|
|
|
|
|
endTime = endTime * 1000 |
|
|
|
|
|
} |
|
|
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
|
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
if !publicmethod.IsInTrue[float64](minVal, valAry) { |
|
|
|
|
|
valAry = append(valAry, minVal) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
jieguo = len(valAry) |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* |
|
|
|
|
|
@ 作者: 秦东 |
|
|
|
|
|
@ 时间: 2025-07-25 14:51:33 |
|
|
|
|
|
@ 功能: |
|
|
|
|
|
|
|
|
|
|
|
#xField X轴信息 |
|
|
|
|
|
#yField Y轴信息 |
|
|
|
|
|
#types 时间信息 |
|
|
|
|
|
#format 值约束 |
|
|
|
|
|
#timeAry 时间数组 |
|
|
|
|
|
*/ |
|
|
|
|
|
func (s *SeriesList) NewmaxData(xField, yField, types string, val interface{}, format int, timeAry []string) { |
|
|
|
|
|
var monthAry []interface{} |
|
|
|
|
|
for _, v := range timeAry { |
|
|
|
|
|
switch types { |
|
|
|
|
|
case "year": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "month": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
|
|
|
|
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
|
|
|
|
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
|
|
|
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMaxData(startTime, endTime.AllTime, val, xField, yField, format)) |
|
|
|
|
|
case "day": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "hour": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "minute": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "second": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
s.Data = monthAry |
|
|
|
|
|
} |
|
|
|
|
|
func (s *SeriesList) QuMaxData(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
|
|
|
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk { |
|
|
|
|
|
var sumVal float64 |
|
|
|
|
|
for i, mv := range yVal { |
|
|
|
|
|
if yVal, isOk := mv[yField]; isOk { |
|
|
|
|
|
if xVal, isOk := mv[xField]; isOk { |
|
|
|
|
|
pageTime, _ := publicmethod.StringToInt64(xVal) |
|
|
|
|
|
if publicmethod.GetIntLength(pageTime) >= 13 { |
|
|
|
|
|
startTime = startTime * 1000 |
|
|
|
|
|
endTime = endTime * 1000 |
|
|
|
|
|
} |
|
|
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
|
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
if i == 0 { |
|
|
|
|
|
sumVal = minVal |
|
|
|
|
|
} else { |
|
|
|
|
|
if sumVal <= minVal { |
|
|
|
|
|
sumVal = minVal |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
jieguo = publicmethod.DataChuli(sumVal, format) |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* |
|
|
|
|
|
@ 作者: 秦东 |
|
|
|
|
|
@ 时间: 2025-07-25 14:51:33 |
|
|
|
|
|
@ 功能: |
|
|
|
|
|
|
|
|
|
|
|
#xField X轴信息 |
|
|
|
|
|
#yField Y轴信息 |
|
|
|
|
|
#types 时间信息 |
|
|
|
|
|
#format 值约束 |
|
|
|
|
|
#timeAry 时间数组 |
|
|
|
|
|
*/ |
|
|
|
|
|
func (s *SeriesList) NewminData(xField, yField, types string, val interface{}, format int, timeAry []string) { |
|
|
|
|
|
var monthAry []interface{} |
|
|
|
|
|
for _, v := range timeAry { |
|
|
|
|
|
switch types { |
|
|
|
|
|
case "year": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "month": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
|
|
|
|
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
|
|
|
|
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
|
|
|
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMinData(startTime, endTime.AllTime, val, xField, yField, format)) |
|
|
|
|
|
case "day": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "hour": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "minute": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "second": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
s.Data = monthAry |
|
|
|
|
|
} |
|
|
|
|
|
func (s *SeriesList) QuMinData(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
|
|
|
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk { |
|
|
|
|
|
var sumVal float64 |
|
|
|
|
|
for i, mv := range yVal { |
|
|
|
|
|
if yVal, isOk := mv[yField]; isOk { |
|
|
|
|
|
if xVal, isOk := mv[xField]; isOk { |
|
|
|
|
|
pageTime, _ := publicmethod.StringToInt64(xVal) |
|
|
|
|
|
if publicmethod.GetIntLength(pageTime) >= 13 { |
|
|
|
|
|
startTime = startTime * 1000 |
|
|
|
|
|
endTime = endTime * 1000 |
|
|
|
|
|
} |
|
|
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
|
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
if i == 0 { |
|
|
|
|
|
sumVal = minVal |
|
|
|
|
|
} else { |
|
|
|
|
|
if sumVal >= minVal { |
|
|
|
|
|
sumVal = minVal |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
jieguo = publicmethod.DataChuli(sumVal, format) |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* |
|
|
|
|
|
@ 作者: 秦东 |
|
|
|
|
|
@ 时间: 2025-07-25 14:51:33 |
|
|
|
|
|
@ 功能: |
|
|
|
|
|
|
|
|
|
|
|
#xField X轴信息 |
|
|
|
|
|
#yField Y轴信息 |
|
|
|
|
|
#types 时间信息 |
|
|
|
|
|
#format 值约束 |
|
|
|
|
|
#timeAry 时间数组 |
|
|
|
|
|
*/ |
|
|
|
|
|
func (s *SeriesList) NewsumData(xField, yField, types string, val interface{}, format int, timeAry []string) { |
|
|
|
|
|
var monthAry []interface{} |
|
|
|
|
|
for _, v := range timeAry { |
|
|
|
|
|
switch types { |
|
|
|
|
|
case "year": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "month": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
|
|
|
|
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
|
|
|
|
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
|
|
|
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
|
|
|
|
|
monthAry = append(monthAry, s.QuSumData(startTime, endTime.AllTime, val, xField, yField, format)) |
|
|
|
|
|
case "day": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "hour": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "minute": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
case "second": |
|
|
|
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
|
|
|
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
|
|
|
|
|
monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
s.Data = monthAry |
|
|
|
|
|
} |
|
|
|
|
|
func (s *SeriesList) QuSumData(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
|
|
|
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk { |
|
|
|
|
|
var sumVal float64 |
|
|
|
|
|
for _, mv := range yVal { |
|
|
|
|
|
if yVal, isOk := mv[yField]; isOk { |
|
|
|
|
|
if xVal, isOk := mv[xField]; isOk { |
|
|
|
|
|
pageTime, _ := publicmethod.StringToInt64(xVal) |
|
|
|
|
|
if publicmethod.GetIntLength(pageTime) >= 13 { |
|
|
|
|
|
startTime = startTime * 1000 |
|
|
|
|
|
endTime = endTime * 1000 |
|
|
|
|
|
} |
|
|
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
|
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
sumVal = sumVal + minVal |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
jieguo = publicmethod.DataChuli(sumVal, format) |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 计算数值
|
|
|
|
|
|
// 1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值
|
|
|
|
|
|
// 当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数;
|
|
|
|
|
|
func (b *BarDataInfo) CalculateNumericalValues(y []YAxisInfo, val interface{}, xField, chartType string, types string, lenght int, timeAry []string) { |
|
|
|
|
|
|
|
|
|
|
|
for _, v := range y { |
|
|
|
|
|
var seriesInfo SeriesList |
|
|
|
|
|
seriesInfo.Name = v.OldTitle |
|
|
|
|
|
seriesInfo.Types = chartType |
|
|
|
|
|
switch v.Method { |
|
|
|
|
|
case 2: |
|
|
|
|
|
seriesInfo.AverageValue(xField, v.Field, types, val, v.Format, lenght, timeAry) |
|
|
|
|
|
case 3: |
|
|
|
|
|
seriesInfo.StatisticalQuantity(xField, v.Field, types, val, v.Format, lenght, timeAry) |
|
|
|
|
|
case 4: |
|
|
|
|
|
seriesInfo.RemoveDuplicateCounts(xField, v.Field, types, val, v.Format, lenght, timeAry) |
|
|
|
|
|
case 5: |
|
|
|
|
|
seriesInfo.maxData(xField, v.Field, types, val, v.Format, lenght, timeAry) |
|
|
|
|
|
case 6: |
|
|
|
|
|
seriesInfo.minData(xField, v.Field, types, val, v.Format, lenght, timeAry) |
|
|
|
|
|
default: |
|
|
|
|
|
seriesInfo.sumData(xField, v.Field, types, val, v.Format, lenght, timeAry) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if !publicmethod.IsInTrue[string](v.OldTitle, b.Legend.Data) { |
|
|
if !publicmethod.IsInTrue[string](v.OldTitle, b.Legend.Data) { |
|
|
@ -130,7 +683,7 @@ func (b *BarDataInfo) CalculateNumericalValues(y []YAxisInfo, val interface{}, x |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 求平均值
|
|
|
// 求平均值
|
|
|
func (s *SeriesList) AverageValue(xField, yField, types string, val interface{}, format, lenght int) { |
|
|
func (s *SeriesList) AverageValue(xField, yField, types string, val interface{}, format, lenght int, timeAry []string) { |
|
|
tayTime := time.Now().Unix() |
|
|
tayTime := time.Now().Unix() |
|
|
switch types { |
|
|
switch types { |
|
|
case "month": |
|
|
case "month": |
|
|
@ -523,7 +1076,7 @@ func (s *SeriesList) AverageValue(xField, yField, types string, val interface{}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 统计数量
|
|
|
// 统计数量
|
|
|
func (s *SeriesList) StatisticalQuantity(xField, yField, types string, val interface{}, format, lenght int) { |
|
|
func (s *SeriesList) StatisticalQuantity(xField, yField, types string, val interface{}, format, lenght int, timeAry []string) { |
|
|
tayTime := time.Now().Unix() |
|
|
tayTime := time.Now().Unix() |
|
|
switch types { |
|
|
switch types { |
|
|
case "month": |
|
|
case "month": |
|
|
@ -852,7 +1405,7 @@ func (s *SeriesList) StatisticalQuantity(xField, yField, types string, val inter |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 去重计数
|
|
|
// 去重计数
|
|
|
func (s *SeriesList) RemoveDuplicateCounts(xField, yField, types string, val interface{}, format, lenght int) { |
|
|
func (s *SeriesList) RemoveDuplicateCounts(xField, yField, types string, val interface{}, format, lenght int, timeAry []string) { |
|
|
tayTime := time.Now().Unix() |
|
|
tayTime := time.Now().Unix() |
|
|
switch types { |
|
|
switch types { |
|
|
case "month": |
|
|
case "month": |
|
|
@ -1201,7 +1754,8 @@ func (s *SeriesList) RemoveDuplicateCounts(xField, yField, types string, val int |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 求和
|
|
|
// 求和
|
|
|
func (s *SeriesList) sumData(xField, yField, types string, val interface{}, format, lenght int) { |
|
|
func (s *SeriesList) sumData(xField, yField, types string, val interface{}, format, lenght int, timeAry []string) { |
|
|
|
|
|
fmt.Printf("求和------------>%v\n\n", lenght) |
|
|
tayTime := time.Now().Unix() |
|
|
tayTime := time.Now().Unix() |
|
|
switch types { |
|
|
switch types { |
|
|
case "month": |
|
|
case "month": |
|
|
@ -1257,6 +1811,7 @@ func (s *SeriesList) sumData(xField, yField, types string, val interface{}, form |
|
|
startTime = startTime * 1000 |
|
|
startTime = startTime * 1000 |
|
|
endTime = endTime * 1000 |
|
|
endTime = endTime * 1000 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
@ -1272,16 +1827,16 @@ func (s *SeriesList) sumData(xField, yField, types string, val interface{}, form |
|
|
jieguo := publicmethod.DataChuli(sumVal, format) |
|
|
jieguo := publicmethod.DataChuli(sumVal, format) |
|
|
dayAry = append(dayAry, jieguo) |
|
|
dayAry = append(dayAry, jieguo) |
|
|
} else { |
|
|
} else { |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 14) |
|
|
ymd := publicmethod.UnixTimeToDay(tayTime, 15) |
|
|
for i := 1; i <= lenght; i++ { |
|
|
for i := 1; i <= lenght; i++ { |
|
|
createTime := fmt.Sprintf("%v %v:00:00", ymd, i) |
|
|
createTime := fmt.Sprintf("%v-%v 00:00:00", ymd, i) |
|
|
if i < 10 { |
|
|
if i < 10 { |
|
|
createTime = fmt.Sprintf("%v 0%v:00:00", ymd, i) |
|
|
createTime = fmt.Sprintf("%v-0%v 00:00:00", ymd, i) |
|
|
} |
|
|
} |
|
|
startTime := publicmethod.DateToTimeStampOld(createTime) |
|
|
startTime := publicmethod.DateToTimeStampOld(createTime) |
|
|
endTimeStr := fmt.Sprintf("%v %v:59:59", ymd, i) |
|
|
endTimeStr := fmt.Sprintf("%v-%v 23:59:59", ymd, i) |
|
|
if i < 10 { |
|
|
if i < 10 { |
|
|
endTimeStr = fmt.Sprintf("%v 0%v:59:59", ymd, i) |
|
|
endTimeStr = fmt.Sprintf("%v-0%v 23:59:59", ymd, i) |
|
|
} |
|
|
} |
|
|
endTime := publicmethod.DateToTimeStampOld(endTimeStr) |
|
|
endTime := publicmethod.DateToTimeStampOld(endTimeStr) |
|
|
var sumVal float64 |
|
|
var sumVal float64 |
|
|
@ -1294,7 +1849,9 @@ func (s *SeriesList) sumData(xField, yField, types string, val interface{}, form |
|
|
startTime = startTime * 1000 |
|
|
startTime = startTime * 1000 |
|
|
endTime = endTime * 1000 |
|
|
endTime = endTime * 1000 |
|
|
} |
|
|
} |
|
|
|
|
|
// fmt.Printf("startTime:%v====>pageTime%v=======endTime%v\n\n", startTime, pageTime, endTime)
|
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
if startTime <= pageTime && pageTime <= endTime { |
|
|
|
|
|
|
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
sumVal = sumVal + minVal |
|
|
sumVal = sumVal + minVal |
|
|
@ -1529,7 +2086,7 @@ func (s *SeriesList) sumData(xField, yField, types string, val interface{}, form |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 求最小值
|
|
|
// 求最小值
|
|
|
func (s *SeriesList) maxData(xField, yField, types string, val interface{}, format, lenght int) { |
|
|
func (s *SeriesList) maxData(xField, yField, types string, val interface{}, format, lenght int, timeAry []string) { |
|
|
var valData float64 = 1 |
|
|
var valData float64 = 1 |
|
|
tayTime := time.Now().Unix() |
|
|
tayTime := time.Now().Unix() |
|
|
switch types { |
|
|
switch types { |
|
|
@ -1666,7 +2223,7 @@ func (s *SeriesList) maxData(xField, yField, types string, val interface{}, form |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 求最小值
|
|
|
// 求最小值
|
|
|
func (s *SeriesList) minData(xField, yField, types string, val interface{}, format, lenght int) { |
|
|
func (s *SeriesList) minData(xField, yField, types string, val interface{}, format, lenght int, timeAry []string) { |
|
|
var valData float64 = 1 |
|
|
var valData float64 = 1 |
|
|
tayTime := time.Now().Unix() |
|
|
tayTime := time.Now().Unix() |
|
|
switch types { |
|
|
switch types { |