浏览代码

fix:柱形图增加单位配置

Roc 1 年之前
父节点
当前提交
7741998bac
共有 4 个文件被更改,包括 24 次插入1 次删除
  1. 12 0
      controllers/chart.go
  2. 4 1
      models/chart.go
  3. 2 0
      models/data_manage/chart_info.go
  4. 6 0
      services/data/chart_info.go

+ 12 - 0
controllers/chart.go

@@ -207,6 +207,12 @@ func (this *ChartController) ChartInfoDetail() {
 	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
 	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
 	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
 	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
 
 
+	// 单位
+	if chartType == utils.CHART_TYPE_BAR && len(yDataList) > 0 {
+		chartInfo.Unit = yDataList[0].Unit
+		chartInfo.UnitEn = yDataList[0].UnitEn
+	}
+
 	resp.ChartInfo = chartInfo
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.EdbInfoList = edbList
 	resp.XEdbIdValue = xEdbIdValue
 	resp.XEdbIdValue = xEdbIdValue
@@ -480,6 +486,12 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (
 	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
 	chartInfo.ChartSource = strings.Join(sourceNameList, ",")
 	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
 	chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
 
 
+	// 单位
+	if chartType == utils.CHART_TYPE_BAR && len(yDataList) > 0 {
+		chartInfo.Unit = yDataList[0].Unit
+		chartInfo.UnitEn = yDataList[0].UnitEn
+	}
+
 	resp.ChartInfo = chartInfo
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.EdbInfoList = edbList
 	resp.XEdbIdValue = xEdbIdValue
 	resp.XEdbIdValue = xEdbIdValue

+ 4 - 1
models/chart.go

@@ -35,7 +35,8 @@ type ChartInfo struct {
 	LeftMin         string    `description:"图表左侧最小值"`
 	LeftMin         string    `description:"图表左侧最小值"`
 	LeftMax         string    `description:"图表左侧最大值"`
 	LeftMax         string    `description:"图表左侧最大值"`
 	Source          int       `description:"1:ETA图库;2:商品价格曲线"`
 	Source          int       `description:"1:ETA图库;2:商品价格曲线"`
-	UnitEn          string    `description:"英文图表名称"`
+	UnitEn          string    `description:"英文图表单位"`
+	Unit            string    `description:"图表单位"`
 	ExtraConfig     string    `description:"图表额外配置,json数据" json:"-"`
 	ExtraConfig     string    `description:"图表额外配置,json数据" json:"-"`
 	ChartSource     string    `description:"图表来源str"`
 	ChartSource     string    `description:"图表来源str"`
 	ChartSourceEn   string    `description:"图表来源(英文)"`
 	ChartSourceEn   string    `description:"图表来源(英文)"`
@@ -187,6 +188,8 @@ type YData struct {
 	M              []int           `description:"对应开始日期的间隔值" json:"-"`
 	M              []int           `description:"对应开始日期的间隔值" json:"-"`
 	NameList       []string        `description:"每个值对应的名称"`
 	NameList       []string        `description:"每个值对应的名称"`
 	EnNameList     []string        `description:"每个值对应的英文名称"`
 	EnNameList     []string        `description:"每个值对应的英文名称"`
+	Unit           string          `description:"中文单位名称"`
+	UnitEn         string          `description:"英文单位名称"`
 }
 }
 
 
 // RollingCorrelationChartDataResp 滚动相关性图
 // RollingCorrelationChartDataResp 滚动相关性图

+ 2 - 0
models/data_manage/chart_info.go

@@ -62,6 +62,8 @@ type BarChartInfoReq struct {
 	EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
 	EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
 	DateList      []BarChartInfoDateReq    `description:"日期配置"`
 	DateList      []BarChartInfoDateReq    `description:"日期配置"`
 	Sort          BarChartInfoSortReq      `description:"排序"`
 	Sort          BarChartInfoSortReq      `description:"排序"`
+	Unit          string                   `description:"中文单位名称"`
+	UnitEn        string                   `description:"英文单位名称"`
 }
 }
 
 
 // BarChartInfoEdbItemReq 柱方图预览请求数据(指标相关)
 // BarChartInfoEdbItemReq 柱方图预览请求数据(指标相关)

+ 6 - 0
services/data/chart_info.go

@@ -123,6 +123,12 @@ func GetChartEdbData(chartInfoId, chartType int, calendar, startDate, endDate st
 				}
 				}
 			}
 			}
 		}
 		}
+
+		for k := range yDataList {
+			yDataList[k].Unit = barChartConf.Unit
+			yDataList[k].UnitEn = barChartConf.UnitEn
+		}
+
 	case 10: // 截面散点图
 	case 10: // 截面散点图
 		sectionScatterConf := extraConfig.(data_manage.SectionScatterReq)
 		sectionScatterConf := extraConfig.(data_manage.SectionScatterReq)
 		xEdbIdValue, dataResp, err = GetSectionScatterChartData(mappingList, edbDataListMap, sectionScatterConf)
 		xEdbIdValue, dataResp, err = GetSectionScatterChartData(mappingList, edbDataListMap, sectionScatterConf)