|
@@ -527,7 +527,7 @@ func GetChartSectionCombineData(chartInfo *data_manage.ChartInfo, mappingList []
|
|
|
}
|
|
|
// 处理系列排序
|
|
|
if extraConfig.SortType > 0 {
|
|
|
- newSeriesDataListMap, newSeriesNoDataIndexMap := sortChartSeriesDataSet(baseSeries.DataList, baseSeries.NoDataEdbIndex, seriesDataListMap, seriesNoDataIndexMap, extraConfig.SortType)
|
|
|
+ newSeriesDataListMap, newSeriesNoDataIndexMap := SortChartSeriesDataSet(baseSeries.SeriesName, baseSeries.DataList, baseSeries.NoDataEdbIndex, seriesDataListMap, seriesNoDataIndexMap, extraConfig.SortType)
|
|
|
for k, item := range extraConfig.SeriesList {
|
|
|
dataList, ok := newSeriesDataListMap[item.SeriesName]
|
|
|
if ok {
|
|
@@ -847,21 +847,22 @@ func handleSystemAppointDateT(currDate time.Time, appointDay, frequency string)
|
|
|
}
|
|
|
|
|
|
// sortTripleDataSet 以第一组数据为基准,排序之后,空数组的位置也要同步变更
|
|
|
-func sortChartSeriesDataSet(baseDataList []float64, baseSeriesNoDataIndexList []int, dataListMap map[string][]float64, noDataListIndexMap map[string][]int, asc int) (newDataListMap map[string][]float64, newNoDataListIndexMap map[string][]int) {
|
|
|
+func SortChartSeriesDataSet(baseName string, baseDataList []float64, baseSeriesNoDataIndexList []int, dataListMap map[string][]float64, noDataListIndexMap map[string][]int, asc int) (newDataListMap map[string][]float64, newNoDataListIndexMap map[string][]int) {
|
|
|
newDataListMap = make(map[string][]float64)
|
|
|
newNoDataListIndexMap = make(map[string][]int)
|
|
|
|
|
|
indices := make([]int, len(baseDataList))
|
|
|
- newIndices := make([]int, len(baseDataList))
|
|
|
+ newIndices := make([]int, len(baseDataList)-len(baseSeriesNoDataIndexList))
|
|
|
// 初始化indices
|
|
|
for i := range indices {
|
|
|
indices[i] = i
|
|
|
}
|
|
|
if len(baseSeriesNoDataIndexList) > 0 { //把空值移动到最右边
|
|
|
- for i, v := range indices {
|
|
|
+ j := 0
|
|
|
+ for i := range indices {
|
|
|
isEmpty := false
|
|
|
- for k := range baseSeriesNoDataIndexList {
|
|
|
- if i == k {
|
|
|
+ for _, v := range baseSeriesNoDataIndexList {
|
|
|
+ if i == v {
|
|
|
isEmpty = true
|
|
|
break
|
|
|
}
|
|
@@ -869,14 +870,18 @@ func sortChartSeriesDataSet(baseDataList []float64, baseSeriesNoDataIndexList []
|
|
|
if isEmpty {
|
|
|
continue
|
|
|
}
|
|
|
- newIndices[i] = v
|
|
|
+ newIndices[j] = i
|
|
|
+ j += 1
|
|
|
}
|
|
|
newIndices = append(newIndices, baseSeriesNoDataIndexList...)
|
|
|
// 根据排序后的indices重新排列所有组的数据
|
|
|
- for i, idx := range indices {
|
|
|
+ for i, idx := range newIndices {
|
|
|
for k, _ := range dataListMap {
|
|
|
- if utils.InArrayByInt(noDataListIndexMap[k], i) { //如果i位置上的数据为空,那么
|
|
|
- newNoDataListIndexMap[k] = append(newNoDataListIndexMap[k], idx)
|
|
|
+ if _, ok := newDataListMap[k]; !ok {
|
|
|
+ newDataListMap[k] = make([]float64, len(baseDataList))
|
|
|
+ }
|
|
|
+ if utils.InArrayByInt(noDataListIndexMap[k], idx) { //如果i位置上的数据为空,那么
|
|
|
+ newNoDataListIndexMap[k] = append(newNoDataListIndexMap[k], i)
|
|
|
}
|
|
|
newDataListMap[k][i] = dataListMap[k][idx]
|
|
|
}
|
|
@@ -885,14 +890,17 @@ func sortChartSeriesDataSet(baseDataList []float64, baseSeriesNoDataIndexList []
|
|
|
noDataListIndexMap = newNoDataListIndexMap
|
|
|
newDataListMap = make(map[string][]float64)
|
|
|
newNoDataListIndexMap = make(map[string][]int)
|
|
|
+ baseDataList, _ = dataListMap[baseName]
|
|
|
//先把空的数据移动到最后面
|
|
|
indices = make([]int, len(baseDataList)-len(baseSeriesNoDataIndexList)) //空值不参与排序
|
|
|
+ newIndices = make([]int, len(baseDataList)) //空值不参与排序
|
|
|
// 初始化indices
|
|
|
for i := range indices {
|
|
|
indices[i] = i
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
+ length := len(indices)
|
|
|
// 根据Group1的数据进行排序,asc决定是升序还是降序
|
|
|
if asc == 1 {
|
|
|
sort.Slice(indices, func(i, j int) bool {
|
|
@@ -904,11 +912,21 @@ func sortChartSeriesDataSet(baseDataList []float64, baseSeriesNoDataIndexList []
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ for i := range newIndices {
|
|
|
+ if i < length {
|
|
|
+ newIndices[i] = indices[i]
|
|
|
+ } else {
|
|
|
+ newIndices[i] = i
|
|
|
+ }
|
|
|
+ }
|
|
|
// 根据排序后的indices重新排列所有组的数据
|
|
|
- for i, idx := range indices {
|
|
|
+ for i, idx := range newIndices {
|
|
|
for k, _ := range dataListMap {
|
|
|
- if utils.InArrayByInt(noDataListIndexMap[k], i) { //如果i位置上的数据为空,那么
|
|
|
- newNoDataListIndexMap[k] = append(newNoDataListIndexMap[k], idx)
|
|
|
+ if _, ok := newDataListMap[k]; !ok {
|
|
|
+ newDataListMap[k] = make([]float64, len(baseDataList))
|
|
|
+ }
|
|
|
+ if utils.InArrayByInt(noDataListIndexMap[k], idx) { //如果i位置上的数据为空,那么
|
|
|
+ newNoDataListIndexMap[k] = append(newNoDataListIndexMap[k], i)
|
|
|
}
|
|
|
newDataListMap[k][i] = dataListMap[k][idx]
|
|
|
}
|