Procházet zdrojové kódy

Merge branch 'need_pool817'

Karsa před 1 rokem
rodič
revize
77466d454a
2 změnil soubory, kde provedl 40 přidání a 13 odebrání
  1. 6 6
      src/components/chart.vue
  2. 34 7
      src/views/chartShow/index.vue

+ 6 - 6
src/components/chart.vue

@@ -31,12 +31,12 @@ export default defineComponent({
       const new_options: any = { ...defaultOpts, ...props.options };
       console.log(new_options);
       
-      // 相关性图设置offset
-      if(new_options.isRelevanceChart){
-        console.log(document.getElementById('container')?.offsetHeight);
-        const h=document.getElementById('container')?.offsetHeight
-        new_options.xAxis.offset=-(h-74)/2
-      }
+      // // 相关性图设置offset
+      // if(new_options.isRelevanceChart){
+      //   console.log(document.getElementById('container')?.offsetHeight);
+      //   const h=document.getElementById('container')?.offsetHeight
+      //   new_options.xAxis.offset=-(h-74)/2
+      // }
       
 
       //stock不支持线形图只支持时间图 画散点图用原始chart

+ 34 - 7
src/views/chartShow/index.vue

@@ -168,7 +168,7 @@ export default defineComponent({
         const sourceTypeMap = {
           2: initCommodityData,
           3: initRelevanceChartData,
-          4: initRelevanceChartData,
+          4: initStatisticChartData,
           5: initCommodityData,
           6: initFittingEquation,
           7: initStatisticChartData,
@@ -208,7 +208,7 @@ export default defineComponent({
           align: 'high',
           rotation: 0,
           x: 0,
-          y:10,
+          y:2,
           offset: 20,
         },
         tickInterval: 1,
@@ -233,11 +233,11 @@ export default defineComponent({
           },
           align: 'center',
         },
-        min: -1,
-        max: 1,
+        // min: -1,
+        // max: 1,
         opposite: false,
         tickWidth: 1,
-        tickInterval:0.2,
+        // tickInterval:0.2,
       }
 
       //处理series
@@ -461,13 +461,15 @@ export default defineComponent({
         }
     }
 
-    /* 统计特征 标准差 百分比 频率 */
-    const initStatisticChartData = (data: { DataResp:any,ChartInfo:any }) => {
+    const correlationChartInfo = ref<any>({});
+    /* 统计特征 标准差 百分比 频率 滚动相关性*/
+    const initStatisticChartData = (data: { DataResp:any,ChartInfo:any,CorrelationChartInfo:any }) => {
       if(data.ChartInfo.Source === 9) { //频率图
         state.statisticFrequencyData = data.DataResp;
         setStatisticFrequency();
       }else {
         state.dataList = [data.DataResp];
+        if(data.ChartInfo.Source === 4) correlationChartInfo.value = data.CorrelationChartInfo;
         setDefaultLineOptions();
       }
     }
@@ -707,6 +709,31 @@ export default defineComponent({
         yAxis: ydata,
         xAxis
       };
+
+      //滚动相关性独立tooltip
+      if(chartInfo.Source === 4) {
+        const relevanceUnitEnMap={
+          '年': 'Year',
+          '季': 'Season',
+          '月': 'Month',
+          '周': 'Week',
+          '天': 'Day',
+        }
+        const { LeadValue,LeadUnit } = correlationChartInfo.value;
+        state.options.tooltip = {
+          formatter: function() {
+            let that:any = this;
+            let str = '';
+            
+            if(language.value=='ch'){
+              str = `${Highcharts.dateFormat('%Y/%m/%d',that.x)}<br><p>相关性系数:${that.y.toFixed(4)}</p><br><p>领先${LeadValue+LeadUnit}</p>`
+            }else{
+              str = `${Highcharts.dateFormat('%Y/%m/%d',that.x)}<br><p>Correlation coefficient:${that.y.toFixed(4)}</p><br><p>lead${LeadValue+relevanceUnitEnMap[LeadUnit]}</p>`
+            }
+            return str
+          },
+        }
+      }
     }
 
     /* 设置x轴步长 刻度数量多一点 */