Эх сурвалжийг харах

历史数据单设备
1、滤波100->30;不为0时默认不展示tooltips;
2、转换阻力单开Y轴展示;
3、修复有线条重复的bug。

git-svn-id: https://202.107.226.68:8443/svn/Services/ResistanceMonitor@44 a05970a1-87b9-9d4f-9ee5-fa77e2ec115b

yinwei 1 жил өмнө
parent
commit
13c39a95ad

+ 96 - 22
2.Web/src/chart/force-curve.js

@@ -22,17 +22,25 @@ function forceOption({
  end_value,
  starttime,
  endtime,
+ threshold,
 }) {
  let series = []
  let legend_data = []
  let y_max = 0 // Y轴最大值
  let y_min = 0 // Y轴最小值
+ let zh_max = 0 // 转换阻力Y轴最大值
+ let zh_min = 0 // 转换阻力Y轴最大值
  let max_min_time = {}
+ let filtering = localStorage.getItem('filtering')
+ let show_tooltips = true
+ if (filtering != 0) {
+  show_tooltips = threshold == 0
+ }
  if (starttime && endtime) {
   max_min_time.min = dayjs(starttime).valueOf()
   max_min_time.max = dayjs(endtime).valueOf()
  }
- // 阻力
+ let zh_regex = /转换|3号/
  if (curve_data_list && curve_data_list.length) {
   legend_data = curve_data_list.map(item => item.name)
   curve_data_list.forEach(element => {
@@ -60,6 +68,7 @@ function forceOption({
     if (!name_list.includes(element.name)) {
      series.push({
       name: element.name,
+      yAxisIndex: zh_regex.test(element.name) ? 2 : 0,
       type: 'line',
       symbol: 'none',
       silent: true, // 开启静默模式
@@ -75,6 +84,7 @@ function forceOption({
     if (!name_list.includes(element.name)) {
      series.push({
       name: element.name,
+      yAxisIndex: zh_regex.test(element.name) ? 2 : 0,
       type: 'line',
       symbol: 'none',
       silent: true, // 开启静默模式
@@ -107,13 +117,21 @@ function forceOption({
 
  // 是否有标识线
  if (line && line.length) {
-  // 判断标识线的最大值最小值
-  //   let line_value_list = line.map(item => item.value)
-  let line_value_list = line.map(item => item.val)
-  y_max = Math.max(...line_value_list)
-  y_min = Math.min(...line_value_list)
-  let line_style = lineStyle(line)
+  // 分开判断标识线的最大值最小值
+  let main_val = line.filter(item => !item.label.includes('扳'))
+  let zhuanhuan_val = line.filter(item => item.label.includes('扳'))
+  // 定反
+  let main_value_list = main_val.map(item => item.val)
+  y_max = Math.max(...main_value_list)
+  y_min = Math.min(...main_value_list)
+  let line_style = lineStyle(main_val, 0)
   series.push(line_style)
+  // 转换阻力
+  let zh_value_list = zhuanhuan_val.map(item => item.val)
+  zh_max = Math.max(...zh_value_list)
+  zh_min = Math.min(...zh_value_list)
+  let zh_style = lineStyle(zhuanhuan_val, 2)
+  series.push(zh_style)
  }
 
  if (refer_curve && refer_curve.length) {
@@ -144,7 +162,7 @@ function forceOption({
    },
   },
   grid: {
-   left: 55,
+   left: 120,
   },
   dataZoom: [
    {
@@ -166,25 +184,27 @@ function forceOption({
    },
   ],
   tooltip: {
+   show: show_tooltips,
    trigger: 'axis',
    backgroundColor: '#232526',
    borderColor: '#606266',
    textStyle: {
     color: '#c0c4cc',
    },
-   //    formatter: params => {
-   //     if (!params.length) return
-   //     let html_list = [],
-   //      label_text = '',
-   //      time_text = ''
-   //     time_text = `${params[0].axisValueLabel}.${dayjs(params[0].axisValue).format('SSS')}`
-   //     html_list.push(time_text)
-   //     params.forEach(item => {
-   //      label_text = `${item.marker}${item.seriesName}:${item.value[1]}`
-   //      html_list.push(label_text)
-   //     })
-   //     return html_list.join('<br>')
-   //    },
+   formatter: params => {
+    if (!params.length) return
+    let new_params = duplicateRemoval(params)
+    let html_list = [],
+     label_text = '',
+     time_text = ''
+    time_text = `${new_params[0].axisValueLabel}`
+    html_list.push(time_text)
+    new_params.forEach(item => {
+     label_text = `${item.marker}${item.seriesName}:${item.value[1]}`
+     html_list.push(label_text)
+    })
+    return html_list.join('<br>')
+   },
   },
   toolbox: {
    right: '200px',
@@ -234,6 +254,7 @@ function forceOption({
     },
    },
    {
+    // 温度
     scale: true, // y轴起始值自适应
     // minInterval: 1,
     position: 'right',
@@ -260,6 +281,44 @@ function forceOption({
      show: false,
     },
    },
+   {
+    //  转换阻力
+    type: 'value',
+    position: 'left',
+    name: `转换阻力`,
+    offset: 60,
+    max: val => {
+     if (zh_max == 0) return
+     if (val.max > zh_max) return val.max
+     else return zh_max
+    },
+    min: val => {
+     if (zh_min == 0) return
+     if (val.min < zh_min) return val.min
+     else return zh_min
+    },
+    axisLine: {
+     show: true,
+     symbol: ['none', 'none'], // 添加箭头
+     lineStyle: {
+      color: 'white',
+     },
+    },
+    splitLine: {
+     show: true,
+     lineStyle: {
+      color: '#CFD6E1',
+      type: 'dashed',
+     },
+    },
+    axisLabel: {
+     show: true,
+     color: 'white',
+    },
+    axisTick: {
+     show: false,
+    },
+   },
   ],
   xAxis: {
    type: 'time',
@@ -289,7 +348,7 @@ function forceOption({
 }
 
 // 获取标识线的配置
-function lineStyle(data) {
+function lineStyle(data, yIndex) {
  let markLine_data = []
  let markPoint_data = []
  // 标识线样式
@@ -315,6 +374,7 @@ function lineStyle(data) {
  // 标识线
  let line_style = {
   type: 'line',
+  yAxisIndex: yIndex,
   lineStyle: { width: 1 },
   showSymbol: false,
   markLine: {
@@ -351,4 +411,18 @@ function referCurve(data) {
  return refer_line
 }
 
+// 对tooltip去重
+function duplicateRemoval(params) {
+ let newParamsName = []
+ params.forEach(item => {
+  let target_data = newParamsName.find(
+   ele => ele.seriesName === item.seriesName && ele.axisValueLabel === item.axisValueLabel
+  )
+  if (!target_data) {
+   newParamsName.push(item)
+  }
+ })
+ return newParamsName
+}
+
 export default forceOption

+ 7 - 3
2.Web/src/views/Force.vue

@@ -1167,7 +1167,7 @@ export default {
     send_data.threshold = Number(this.threshold_val)
     localStorage.setItem('threshold_val', this.threshold_val)
    } else {
-    send_data.threshold = 100
+    send_data.threshold = 30
    }
    this.curve_data = new Object()
    let date_num = +new Date()
@@ -1191,7 +1191,7 @@ export default {
      this.is_nodata = true
      let num_list = res.data.map(item => item.points.length || 0)
      let sum = num_list.reduce((total, current) => total + current, 0)
-     this.curve_data.force_unit = '单位:' + res.unit
+     this.curve_data.force_unit = `定/反位:` + res.unit
      this.curve_data.curve_data_list = _.cloneDeep(res.data)
      if (res.warn_line && res.warn_line.length) {
       this.warn_line_data = _.cloneDeep(res.warn_line)
@@ -1214,6 +1214,7 @@ export default {
      }
      this.curve_data.starttime = starttime
      this.curve_data.endtime = endtime
+     this.curve_data.threshold = send_data.threshold
      console.log(`2.处理数据耗时:${+new Date() - date_num} ms`)
      this.draw_line_curve()
      if (res.has_more) {
@@ -1879,7 +1880,7 @@ export default {
    //  let unix_time = this.$dayjs(times).unix() * 1000
    //  this.times = [unix_time - 2 * 60 * 60 * 1000, unix_time]
    //  this.times = [1714764900000, 1714766100000] // 2024年5月4号有数据
-   this.times = [1716307200000, 1716393600000] // 2024年5月22~23号有数据
+   //  this.times = [1716307200000, 1716393600000] // 2024年5月22~23号有数据
    //  this.times = [1715961600000, 1716048000000] // 2024年5月18~19号有数据
    //  this.times = [1715988120000, 1715988540000] // 2024年5月18~19号7点数据
   },
@@ -1904,6 +1905,9 @@ export default {
  mounted() {
   this.get_conf_read()
   this.url_is_query()
+  // setTimeout(() => {
+  //  this.search_data = '108'
+  // }, 300)
  },
  beforeDestroy() {
   // this.myCharts.clear()