소스 검색

🦄 refactor(设备监控曲线): 调整y轴显示,和区间

Zimo 1 주 전
부모
커밋
85db3bb36c
1개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 3
      src/views/pms/device/monitor/TdDeviceInfo.vue

+ 7 - 3
src/views/pms/device/monitor/TdDeviceInfo.vue

@@ -238,11 +238,11 @@ const render = () => {
 
   const values = Object.values(chartMap.value).flatMap((item) => item.value.map((d) => d.value))
 
-  const maxVal = Math.max(...values)
+  const maxVal = Math.max(...values, 10000)
   const minVal = Math.min(...values, -100)
 
   const maxDigits = (Math.floor(maxVal) + '').length
-  const minDigits = (Math.floor(Math.abs(minVal)) + '').length
+  const minDigits = (Math.floor(Math.abs(minVal)) + '').length - 1
   const interval = Math.max(maxDigits, minDigits)
 
   maxInterval = interval
@@ -285,7 +285,11 @@ const render = () => {
       max: maxInterval,
       interval: 1,
       axisLabel: {
-        formatter: (v) => (v === 0 ? '0' : v > 0 ? Math.pow(10, v) : -Math.pow(10, -v))
+        formatter: (v) => {
+          const num = v === 0 ? 0 : v > 0 ? Math.pow(10, v) : -Math.pow(10, -v)
+
+          return num.toLocaleString()
+        }
       }
     },
     legend: {