Sfoglia il codice sorgente

Merge branch 'ETA_1.9.0_v2' into debug

zwxi 9 mesi fa
parent
commit
bcbfc98bfa

+ 8 - 1
controllers/data_manage/chart_info.go

@@ -1503,7 +1503,14 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 		br.ErrMsg = "获取主题信息失败,Err:" + err.Error()
 		return
 	}
-	chartInfo.ChartThemeStyle = chartTheme.Config
+	// 兼容历史数据,加入新字段LineOptionList
+	newConfig, e := data.ConvertOldChartOptions(chartTheme.Config)
+	if e != nil {
+		chartInfo.ChartThemeStyle = chartTheme.Config
+	} else {
+		chartInfo.ChartThemeStyle = newConfig
+	}
+
 	chartInfo.ChartThemeId = chartTheme.ChartThemeId
 
 	dateType := chartInfo.DateType

+ 9 - 8
models/data_manage/chart_theme/request/theme.go

@@ -76,14 +76,15 @@ type LineOptions struct {
 }
 
 type OldChartOptions struct {
-	ColorsOptions []string    `json:"colorsOptions"`
-	LineOptions   LineOptions `json:"lineOptions"`
-	LegendOptions interface{} `json:"legendOptions"`
-	TitleOptions  interface{} `json:"titleOptions"`
-	MarkerOptions interface{} `json:"markerOptions"`
-	XAxisOptions  interface{} `json:"xAxisOptions"`
-	YAxisOptions  interface{} `json:"yAxisOptions"`
-	DrawOption    interface{} `json:"drawOption"`
+	ColorsOptions  []string         `json:"colorsOptions"`
+	LineOptions    LineOptions      `json:"lineOptions"`
+	LegendOptions  interface{}      `json:"legendOptions"`
+	TitleOptions   interface{}      `json:"titleOptions"`
+	MarkerOptions  interface{}      `json:"markerOptions"`
+	XAxisOptions   interface{}      `json:"xAxisOptions"`
+	YAxisOptions   interface{}      `json:"yAxisOptions"`
+	DrawOption     interface{}      `json:"drawOption"`
+	LineOptionList []NewLineOptions `json:"lineOptionList"`
 }
 
 type NewChartOptions struct {

+ 23 - 20
services/data/chart_theme.go

@@ -615,24 +615,27 @@ func GetChartThemeConfig(chartThemeId, source, chartType int) (chartTheme *chart
 func ConvertOldChartOptions(config string) (newConfig string, err error) {
 	var oldTheme request.OldChartOptions
 
-		var newTheme request.NewChartOptions
-		err = json.Unmarshal([]byte(config), &oldTheme)
-		if err != nil {
-			return
-		}
-		newTheme.OldChartOptions = oldTheme
-		for i := 0; i < 10; i++ {
-			newLineOption := request.NewLineOptions{
-				LineOptions: oldTheme.LineOptions,
-				Color:       oldTheme.ColorsOptions[i],
-				DataMark:    "none",
-				MarkType:    "square",
-				MarkSize:    5,
-				MarkColor:   oldTheme.ColorsOptions[i],
-			}
-			newTheme.LineOptionList = append(newTheme.LineOptionList, newLineOption)
-		}
-		newThemeStr, _ := json.Marshal(newTheme)
-		newConfig = string(newThemeStr)
+	var newTheme request.NewChartOptions
+	err = json.Unmarshal([]byte(config), &oldTheme)
+	if err != nil {
 		return
-}
+	}
+	if oldTheme.LineOptionList != nil && len(oldTheme.LineOptionList) > 0 {
+		return
+	}
+	newTheme.OldChartOptions = oldTheme
+	for i := 0; i < 10; i++ {
+		newLineOption := request.NewLineOptions{
+			LineOptions: oldTheme.LineOptions,
+			Color:       oldTheme.ColorsOptions[i],
+			DataMark:    "none",
+			MarkType:    "square",
+			MarkSize:    5,
+			MarkColor:   oldTheme.ColorsOptions[i],
+		}
+		newTheme.LineOptionList = append(newTheme.LineOptionList, newLineOption)
+	}
+	newThemeStr, _ := json.Marshal(newTheme)
+	newConfig = string(newThemeStr)
+	return
+}