Ver Fonte

Merge branch 'bug_5274' into custom

Karsa há 5 meses atrás
pai
commit
31df53bc10
1 ficheiros alterados com 9 adições e 3 exclusões
  1. 9 3
      src/hooks/chart/useChartRender.ts

+ 9 - 3
src/hooks/chart/useChartRender.ts

@@ -360,6 +360,8 @@ const setSeasonOptions = (data:any) => {
   // 跟颜色对应
   chartTheme && (chartTheme.lineOptionList=chartTheme.lineOptionList.reverse().slice(-chartDataHandle.length))
 
+  let maxDateRange=0
+
   /*处理数据列 常规左轴*/
   for (let index in chartDataHandle) {
     console.log(index,'index');
@@ -385,6 +387,11 @@ const setSeasonOptions = (data:any) => {
       ...predict_params
     };
     const data_array = _.cloneDeep(j.DataList);
+    
+    let dateRange = data_array[data_array.length-1].DataTimestamp - data_array[0].DataTimestamp
+    // 时间范围
+    maxDateRange=Math.max(maxDateRange,dateRange)
+    
     data_array &&
       data_array.forEach((item: IParams) => {
         serie_item.data.push([item.DataTimestamp, item.Value]);
@@ -536,11 +543,10 @@ const setSeasonOptions = (data:any) => {
           min: Number(rightMin),
     })
   }
-
-  // 季节图x轴显示月/日
+  // 季节图x轴显示月/日  
   const xAxis = {
     ...defaultOpts.xAxis,
-    tickInterval:  screen.value === 'phone' ? 24 * 3600 * 1000 * 60 : undefined,
+    tickInterval:  screen.value === 'phone' ? maxDateRange/6 || undefined : undefined,
     labels: {
       formatter: function (ctx: any) {
         return Highcharts.dateFormat('%m/%d', ctx.value);