...
|
...
|
@@ -706,21 +706,33 @@ func histogramStatisticsByMonth(start time.Time) ([]queryItem, []string) { |
|
|
var monthEnd = time.Date(year, month+1, 1, 0, 0, 0, 0, time.Local).Add(-time.Second)
|
|
|
var xAxisData []string
|
|
|
for {
|
|
|
if beginTime.AddDate(0, 0, increaseDay).After(monthEnd) {
|
|
|
currentIncreaseDay := increaseDay
|
|
|
leftDay := monthEnd.Day() - endTime.Day()
|
|
|
if leftDay == 0 {
|
|
|
break
|
|
|
}
|
|
|
// 不足5天的情况,比如二月 28、29天
|
|
|
if leftDay > 0 && leftDay < increaseDay {
|
|
|
currentIncreaseDay = leftDay
|
|
|
}
|
|
|
if beginTime.AddDate(0, 0, currentIncreaseDay).After(monthEnd) {
|
|
|
endTime = monthEnd
|
|
|
break
|
|
|
} else {
|
|
|
endTime = beginTime.AddDate(0, 0, increaseDay).Add(-time.Second)
|
|
|
endTime = beginTime.AddDate(0, 0, currentIncreaseDay).Add(-time.Second)
|
|
|
}
|
|
|
item := queryItem{
|
|
|
BeginTime: beginTime,
|
|
|
EndTime: beginTime.AddDate(0, 0, increaseDay).Add(-time.Second),
|
|
|
EndTime: beginTime.AddDate(0, 0, currentIncreaseDay).Add(-time.Second),
|
|
|
}
|
|
|
// 30号接近月末时,如果有31号 就取月末值
|
|
|
left := monthEnd.Day() - item.EndTime.Day()
|
|
|
if left <= 1 {
|
|
|
item.EndTime = monthEnd
|
|
|
endTime = monthEnd
|
|
|
}
|
|
|
xAxisData = append(xAxisData, item.EndTime.Format("01-02"))
|
|
|
beginTime = endTime
|
|
|
if endTime == monthEnd {
|
|
|
break
|
|
|
}
|
|
|
ret = append(ret, item)
|
|
|
}
|
|
|
return ret, xAxisData
|
...
|
...
|
|