Explorar el Código

指标图 农历图逻辑回滚

hbchen hace 1 año
padre
commit
15023d30a3

+ 87 - 89
src/views/dataEntry_manage/databaseComponents/chartTrendRender.vue

@@ -537,17 +537,12 @@ export default {
 		setSeasonOptions() {
 			console.log(this.tableData)
       const chartData = _.cloneDeep(this.tableData);
-
-			// 农历数据需要去除第一项 在ETA1.0.5之后,除了这里 农历和公历处理逻辑一样
-			const chartDataHandle=this.calendar_type === '农历'?
-												chartData.List.filter((item, index) => index > 0):
-												chartData
       let seasonYdata = [],
         seasonData = [];
 
         /* 公历数据处理 处理数据列 y轴 */
-        // if (this.calendar_type === '公历')
-        for (let j of chartDataHandle) {
+        if (this.calendar_type === '公历')
+        for (let j of chartData) {
           
           let serie_item = {
             data: [],
@@ -560,7 +555,7 @@ export default {
             data_array.forEach((item) => {
               serie_item.data.push([item.DataTimestamp, item.Value]);
             });
-          const index = chartDataHandle.findIndex(
+          const index = chartData.findIndex(
             (item) => item.Year === j.Year
           );
           const s_yItem = {
@@ -588,48 +583,48 @@ export default {
         }
 
       /* 农历数据处理  */
-      // let filterArr =
-      //   this.calendar_type === '农历'
-      //     ? chartData.List.filter((item, index) => index > 0)
-      //     : [];
-      // if (this.calendar_type === '农历')
-      //   for (let j of filterArr) {
-
-      //     let serie_item = {
-      //       data: [],
-      //       type: 'spline',
-      //       yAxis: 0,
-      //       name: j.Year
-      //     };
-      //     const data_array = _.cloneDeep(j.Items);
-      //     data_array &&
-      //       data_array.forEach((item) => {
-      //         serie_item.data.push([item.DataTimestamp, item.Value]);
-      //       });
-      //     const index = filterArr.findIndex((item) => item.Year === j.Year);
-      //     const s_yItem = {
-      //       labels: {
-      //         formatter: function () {
-      //           let val = this.value;
-      //           return index !== 0 ? '' : val;
-      //         },
-      //         align: 'center',
-      //       },
-      //       title: {
-      //         text:  this.chartLang=='ch'?this.chartInfo.Unit:
-			// 				!this.chartInfo.UnitEn && this.chartInfo.Unit && this.chartInfo.Unit!='无' ? '英文单位':this.chartInfo.UnitEn,
-      //         align: 'high',
-      //         rotation: 0,
-      //         y: -15,
-      //         offset: -(12 * this.chartInfo.Unit.length),
-      //       },
-      //       max: Number(this.chartInfo.MaxValue),
-      //       min: Number(this.chartInfo.MinValue),
-      //       ...seasonOptions.yAxis,
-      //     };
-      //     seasonData.push(serie_item);
-      //     seasonYdata.push(s_yItem);
-      //   }
+      let filterArr =
+        this.calendar_type === '农历'
+          ? chartData.List.filter((item, index) => index > 0)
+          : [];
+      if (this.calendar_type === '农历')
+        for (let j of filterArr) {
+
+          let serie_item = {
+            data: [],
+            type: 'spline',
+            yAxis: 0,
+            name: j.Year
+          };
+          const data_array = _.cloneDeep(j.Items);
+          data_array &&
+            data_array.forEach((item) => {
+              serie_item.data.push([item.DataTimestamp, item.Value]);
+            });
+          const index = filterArr.findIndex((item) => item.Year === j.Year);
+          const s_yItem = {
+            labels: {
+              formatter: function () {
+                let val = this.value;
+                return index !== 0 ? '' : val;
+              },
+              align: 'center',
+            },
+            title: {
+              text:  this.chartLang=='ch'?this.chartInfo.Unit:
+							!this.chartInfo.UnitEn && this.chartInfo.Unit && this.chartInfo.Unit!='无' ? '英文单位':this.chartInfo.UnitEn,
+              align: 'high',
+              rotation: 0,
+              y: -15,
+              offset: -(12 * this.chartInfo.Unit.length),
+            },
+            max: Number(this.chartInfo.MaxValue),
+            min: Number(this.chartInfo.MinValue),
+            ...seasonOptions.yAxis,
+          };
+          seasonData.push(serie_item);
+          seasonYdata.push(s_yItem);
+        }
 
       /* x轴显示月日  提示框显示月日*/
       defaultOpts.xAxis.labels = {
@@ -649,49 +644,52 @@ export default {
         },
         xDateFormat: '%m/%d',
       }
-      // let rangeSelector =
-      //   this.calendar_type === '农历'
-      //     ? {
-      //         enabled: true,
-      //         selected: 0,
-      //         inputStyle: {
-      //           display: 'none',
-      //         },
-      //         labelStyle: {
-      //           display: 'none',
-      //         },
-      //         buttonTheme: {
-      //           style: {
-      //             display: 'none',
-      //           },
-      //         },
-      //         buttons: [
-      //           {
-      //             type: 'month',
-      //             count: 12,
-      //             text: '12月',
-      //           },
-      //           {
-      //             type: 'month',
-      //             count: 15,
-      //             text: '15月',
-      //           },
-      //           {
-      //             type: 'all',
-      //             text: '全部',
-      //             type: 'all',
-      //           },
-      //         ],
-      //       }
-      //     : {
-      //         enabled: false,
-      //       };
+      let rangeSelector =
+        this.calendar_type === '农历'
+          ? {
+              enabled: true,
+              selected: 0,
+              inputStyle: {
+                display: 'none',
+              },
+              labelStyle: {
+                display: 'none',
+              },
+              buttonTheme: {
+                style: {
+                  display: 'none',
+                },
+              },
+              buttons: [
+                {
+                  type: 'month',
+                  count: 12,
+                  text: '12月',
+                },
+                {
+                  type: 'month',
+                  count: 15,
+                  text: '15月',
+                },
+                {
+                  type: 'all',
+                  text: '全部',
+                  type: 'all',
+                },
+              ],
+            }
+          : {
+              enabled: false,
+            };
 
       this.options = {
-				colors:seasonOptions.colors.slice(-chartDataHandle.length),
+				colors:
+				this.calendar_type === '公历'
+            ? seasonOptions.colors.slice(-chartData.length)
+            : seasonOptions.colors.slice(-filterArr.length),
         series: seasonData,
         yAxis: seasonYdata,
-        // rangeSelector,
+        rangeSelector,
         tooltip
       };
 			console.log(this.options)

+ 87 - 88
src/views/dataEntry_manage/databaseComponents/createChart.vue

@@ -519,16 +519,12 @@ export default {
 			console.log(this.tableData)
       const chartData = _.cloneDeep(this.tableData);
 
-			// 农历数据需要去除第一项 在ETA1.0.5之后,除了这里 农历和公历处理逻辑一样
-			const chartDataHandle=this.calendar_type === '农历'?
-												chartData.List.filter((item, index) => index > 0):
-												chartData
       let seasonYdata = [],
         seasonData = [];
 
         /* 公历数据处理 处理数据列 y轴 */
-        // if (this.calendar_type === '公历')
-        for (let j of chartDataHandle) {
+        if (this.calendar_type === '公历')
+        for (let j of chartData) {
           
           let serie_item = {
             data: [],
@@ -541,7 +537,7 @@ export default {
             data_array.forEach((item) => {
               serie_item.data.push([item.DataTimestamp, item.Value]);
             });
-          const index = chartDataHandle.findIndex(
+          const index = chartData.findIndex(
             (item) => item.Year === j.Year
           );
           const s_yItem = {
@@ -569,48 +565,48 @@ export default {
         }
 
       /* 农历数据处理  */
-      // let filterArr =
-      //   this.calendar_type === '农历'
-      //     ? chartData.List.filter((item, index) => index > 0)
-      //     : [];
-      // if (this.calendar_type === '农历')
-      //   for (let j of filterArr) {
-
-      //     let serie_item = {
-      //       data: [],
-      //       type: 'spline',
-      //       yAxis: 0,
-      //       name: j.Year
-      //     };
-      //     const data_array = _.cloneDeep(j.Items);
-      //     data_array &&
-      //       data_array.forEach((item) => {
-      //         serie_item.data.push([item.DataTimestamp, item.Value]);
-      //       });
-      //     const index = filterArr.findIndex((item) => item.Year === j.Year);
-      //     const s_yItem = {
-      //       labels: {
-      //         formatter: function () {
-      //           let val = this.value;
-      //           return index !== 0 ? '' : val;
-      //         },
-      //         align: 'center',
-      //       },
-      //       title: {
-      //         text:  this.chartLang=='ch'?this.chartInfo.Unit:
-			// 				!this.chartInfo.UnitEn && this.chartInfo.Unit && this.chartInfo.Unit!='无' ? '英文单位':this.chartInfo.UnitEn,
-      //         align: 'high',
-      //         rotation: 0,
-      //         y: -15,
-      //         offset: -(12 * this.chartInfo.Unit.length),
-      //       },
-      //       max: Number(this.chartInfo.MaxValue),
-      //       min: Number(this.chartInfo.MinValue),
-      //       ...seasonOptions.yAxis,
-      //     };
-      //     seasonData.push(serie_item);
-      //     seasonYdata.push(s_yItem);
-      //   }
+      let filterArr =
+        this.calendar_type === '农历'
+          ? chartData.List.filter((item, index) => index > 0)
+          : [];
+      if (this.calendar_type === '农历')
+        for (let j of filterArr) {
+
+          let serie_item = {
+            data: [],
+            type: 'spline',
+            yAxis: 0,
+            name: j.Year
+          };
+          const data_array = _.cloneDeep(j.Items);
+          data_array &&
+            data_array.forEach((item) => {
+              serie_item.data.push([item.DataTimestamp, item.Value]);
+            });
+          const index = filterArr.findIndex((item) => item.Year === j.Year);
+          const s_yItem = {
+            labels: {
+              formatter: function () {
+                let val = this.value;
+                return index !== 0 ? '' : val;
+              },
+              align: 'center',
+            },
+            title: {
+              text:  this.chartLang=='ch'?this.chartInfo.Unit:
+							!this.chartInfo.UnitEn && this.chartInfo.Unit && this.chartInfo.Unit!='无' ? '英文单位':this.chartInfo.UnitEn,
+              align: 'high',
+              rotation: 0,
+              y: -15,
+              offset: -(12 * this.chartInfo.Unit.length),
+            },
+            max: Number(this.chartInfo.MaxValue),
+            min: Number(this.chartInfo.MinValue),
+            ...seasonOptions.yAxis,
+          };
+          seasonData.push(serie_item);
+          seasonYdata.push(s_yItem);
+        }
 
       /* x轴显示月日  提示框显示月日*/
       defaultOpts.xAxis.labels = {
@@ -630,49 +626,52 @@ export default {
         },
         xDateFormat: '%m/%d',
       }
-      // let rangeSelector =
-      //   this.calendar_type === '农历'
-      //     ? {
-      //         enabled: true,
-      //         selected: 0,
-      //         inputStyle: {
-      //           display: 'none',
-      //         },
-      //         labelStyle: {
-      //           display: 'none',
-      //         },
-      //         buttonTheme: {
-      //           style: {
-      //             display: 'none',
-      //           },
-      //         },
-      //         buttons: [
-      //           {
-      //             type: 'month',
-      //             count: 12,
-      //             text: '12月',
-      //           },
-      //           {
-      //             type: 'month',
-      //             count: 15,
-      //             text: '15月',
-      //           },
-      //           {
-      //             type: 'all',
-      //             text: '全部',
-      //             type: 'all',
-      //           },
-      //         ],
-      //       }
-      //     : {
-      //         enabled: false,
-      //       };
+      let rangeSelector =
+        this.calendar_type === '农历'
+          ? {
+              enabled: true,
+              selected: 0,
+              inputStyle: {
+                display: 'none',
+              },
+              labelStyle: {
+                display: 'none',
+              },
+              buttonTheme: {
+                style: {
+                  display: 'none',
+                },
+              },
+              buttons: [
+                {
+                  type: 'month',
+                  count: 12,
+                  text: '12月',
+                },
+                {
+                  type: 'month',
+                  count: 15,
+                  text: '15月',
+                },
+                {
+                  type: 'all',
+                  text: '全部',
+                  type: 'all',
+                },
+              ],
+            }
+          : {
+              enabled: false,
+            };
 
       this.options = {
-        colors:seasonOptions.colors.slice(-chartDataHandle.length),
+        colors:
+				this.calendar_type === '公历'
+            ? seasonOptions.colors.slice(-chartData.length)
+            : seasonOptions.colors.slice(-filterArr.length),
         series: seasonData,
         yAxis: seasonYdata,
-        // rangeSelector,
+        rangeSelector,
         tooltip
       };
 			console.log(this.options)

+ 39 - 41
src/views/dataEntry_manage/mixins/chartPublic.js

@@ -758,9 +758,7 @@ export const chartSetMixin = {
       // 农历数据需要去除第一项  农历和公历处理逻辑一样
       /**
        * isPredictorChart - 预测指标的chartInfo.vue组件内定义的变量
-       * 后端为了去除与预测指标季节性图不必要的逻辑,预测指标返回的图例名称字段是Year而图库返回的是ChartLegend
-       * 农历返回的数据是和 指标库 那边的数据一样 数据在DataList里面又包了一层List,里面列表的字段还是Items
-       * 这边需要做个兼容
+       * 预测指标成图 还是之前农历图的逻辑,有空再拆吧,做个兼容
       */
       const chartDataHandle=this.calendar_type === '农历'?
                             this.isPredictorChart?chartData.DataList.List.filter((item, index) => index > 0):
@@ -887,49 +885,49 @@ export const chartSetMixin = {
         },
         xDateFormat: '%m/%d',
       }
-      // let rangeSelector =
-      //   this.calendar_type === '农历'
-      //     ? {
-      //         enabled: true,
-      //         selected: 0,
-      //         inputStyle: {
-      //           display: 'none',
-      //         },
-      //         labelStyle: {
-      //           display: 'none',
-      //         },
-      //         buttonTheme: {
-      //           style: {
-      //             display: 'none',
-      //           },
-      //         },
-      //         buttons: [
-      //           {
-      //             type: 'month',
-      //             count: 12,
-      //             text: '12月',
-      //           },
-      //           {
-      //             type: 'month',
-      //             count: 15,
-      //             text: '15月',
-      //           },
-      //           {
-      //             type: 'all',
-      //             text: '全部',
-      //             type: 'all',
-      //           },
-      //         ],
-      //       }
-      //     : {
-      //         enabled: false,
-      //       };
+      let rangeSelector =
+        this.calendar_type === '农历' && this.isPredictorChart
+          ? {
+              enabled: true,
+              selected: 0,
+              inputStyle: {
+                display: 'none',
+              },
+              labelStyle: {
+                display: 'none',
+              },
+              buttonTheme: {
+                style: {
+                  display: 'none',
+                },
+              },
+              buttons: [
+                {
+                  type: 'month',
+                  count: 12,
+                  text: '12月',
+                },
+                {
+                  type: 'month',
+                  count: 15,
+                  text: '15月',
+                },
+                {
+                  type: 'all',
+                  text: '全部',
+                  type: 'all',
+                },
+              ],
+            }
+          : {
+              enabled: false,
+            };
 
       this.options = {
         colors:seasonOptions.colors.slice(-chartDataHandle.length),
         series: seasonData,
         yAxis: seasonYdata,
-        // rangeSelector,
+        rangeSelector,
         tooltip
       };
       if(this.currentLang=='en') this.changeOptions()