Răsfoiți Sursa

fix: 季节图标识线取年问题

shanbinzhang 1 lună în urmă
părinte
comite
060e5c1233
1 a modificat fișierele cu 15 adăugiri și 3 ștergeri
  1. 15 3
      src/views/dataEntry_manage/mixins/chartPublic.js

+ 15 - 3
src/views/dataEntry_manage/mixins/chartPublic.js

@@ -3037,6 +3037,7 @@ export const chartSetMixin = {
       axisType表示x轴类型 处理时间轴的值 datetime/null 
     */
     setAxisPlotLines(axis,axisType=null) {
+      console.log(this.chartInfo)
       const { MarkersLines,ChartType } = this.chartInfo;
       if(!MarkersLines) return []
       
@@ -3049,7 +3050,13 @@ export const chartSetMixin = {
         let markerValue='';
         if(isXDateAxis) {
           //季节图x轴额外拼个年份
-          let nowYear = ChartType===2 ? new Date(this.tableData[0].DataList[1].DataList[0].DataTimestamp).getFullYear() : '';
+          let nowYear = '';
+          if(ChartType===2) {  //随意取个数据点的年份即可
+            let data = this.tableData[0].DataList;
+            nowYear = (data[0].DataList&&data[0].DataList.length)
+              ? new Date(data[0].DataList[0].DataTimestamp).getFullYear()
+              : new Date(data[1].DataList[0].DataTimestamp).getFullYear();
+          }
           console.log(nowYear)
           markerValue = ChartType===2 
             ? new Date(`${nowYear}-${_.value}`).getTime()
@@ -3090,8 +3097,13 @@ export const chartSetMixin = {
         let fromMarkerValue='',toMarkerValue='';
         if(isXDateAxis) {
           //季节图x轴额外拼个年份
-          let nowYear = ChartType===2 ? new Date(this.tableData[0].DataList[1].DataList
-            [0].DataTimestamp).getFullYear() : '';
+          let nowYear = '';
+          if(ChartType===2) {  //随意取个数据点的年份即可
+            let data = this.tableData[0].DataList;
+            nowYear = (data[0].DataList&&data[0].DataList.length)
+              ? new Date(data[0].DataList[0].DataTimestamp).getFullYear()
+              : new Date(data[1].DataList[0].DataTimestamp).getFullYear();
+          }
           fromMarkerValue = ChartType===2 
             ? new Date(`${nowYear}-${_.fromValue}`).getTime()
             : new Date(_.fromValue).getTime()