Jelajahi Sumber

Merge branch 'bug_5274'

Karsa 3 bulan lalu
induk
melakukan
f7bfaf6929
1 mengubah file dengan 9 tambahan dan 3 penghapusan
  1. 9 3
      src/hooks/chart/useChartRender.ts

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

@@ -540,6 +540,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');
@@ -565,6 +567,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]);
@@ -716,11 +723,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);