Bladeren bron

历史数据单设备增加双坐标系切换。

git-svn-id: https://202.107.226.68:8443/svn/Services/ResistanceMonitor@53 a05970a1-87b9-9d4f-9ee5-fa77e2ec115b
yinwei 1 jaar geleden
bovenliggende
commit
3e487b7b27
2 gewijzigde bestanden met toevoegingen van 51 en 18 verwijderingen
  1. 23 6
      2.Web/src/chart/force-curve.js
  2. 28 12
      2.Web/src/views/Force.vue

+ 23 - 6
2.Web/src/chart/force-curve.js

@@ -23,6 +23,7 @@ function forceOption({
  starttime,
  endtime,
  threshold,
+ coordinate_state,
 }) {
  let series = []
  let legend_data = []
@@ -44,6 +45,7 @@ function forceOption({
  if (curve_data_list && curve_data_list.length) {
   legend_data = curve_data_list.map(item => item.name)
   curve_data_list.forEach(element => {
+   let yAxisIndex = 0
    let name_list = series.map(item => item.name).filter(Boolean)
    if (element.mark_points && element.mark_points.length) {
     let mark_points = []
@@ -66,9 +68,14 @@ function forceOption({
      })
     })
     if (!name_list.includes(element.name)) {
+     if (coordinate_state) {
+      yAxisIndex = zh_regex.test(element.name) ? 2 : 0
+     } else {
+      yAxisIndex = 0
+     }
      series.push({
       name: element.name,
-      yAxisIndex: zh_regex.test(element.name) ? 2 : 0,
+      yAxisIndex,
       type: 'line',
       symbol: 'none',
       silent: true, // 开启静默模式
@@ -82,9 +89,14 @@ function forceOption({
     }
    } else {
     if (!name_list.includes(element.name)) {
+     if (coordinate_state) {
+      yAxisIndex = zh_regex.test(element.name) ? 2 : 0
+     } else {
+      yAxisIndex = 0
+     }
      series.push({
       name: element.name,
-      yAxisIndex: zh_regex.test(element.name) ? 2 : 0,
+      yAxisIndex,
       type: 'line',
       symbol: 'none',
       silent: true, // 开启静默模式
@@ -124,13 +136,13 @@ function forceOption({
   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)
+  let line_style = lineStyle(main_val, 0, coordinate_state)
   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)
+  let zh_style = lineStyle(zhuanhuan_val, 2, coordinate_state)
   series.push(zh_style)
  }
 
@@ -286,6 +298,7 @@ function forceOption({
     type: 'value',
     position: 'left',
     name: `转换阻力`,
+    show: coordinate_state,
     offset: 60,
     max: val => {
      if (zh_max == 0) return
@@ -348,7 +361,7 @@ function forceOption({
 }
 
 // 获取标识线的配置
-function lineStyle(data, yIndex) {
+function lineStyle(data, yIndex, coordinate_state) {
  let markLine_data = []
  let markPoint_data = []
  // 标识线样式
@@ -372,9 +385,13 @@ function lineStyle(data, yIndex) {
   })
  })
  // 标识线
+ let yAxisIndex = 0
+ if (coordinate_state) {
+  yAxisIndex = yIndex
+ }
  let line_style = {
   type: 'line',
-  yAxisIndex: yIndex,
+  yAxisIndex,
   lineStyle: { width: 1 },
   showSymbol: false,
   markLine: {

+ 28 - 12
2.Web/src/views/Force.vue

@@ -118,7 +118,7 @@
    <!-- 参考曲线工具栏 -->
    <div class="refer_curve_tools">
     <el-button
-     style="margin-left:8px;"
+     style="margin-left:5px;"
      type="primary"
      size="mini"
      @click="setting_params"
@@ -126,7 +126,7 @@
      >报警设置</el-button
     >
     <el-button
-     style="margin-left:8px;"
+     style="margin-left:5px;"
      type="primary"
      size="mini"
      @click="localtion_curve_compare"
@@ -135,7 +135,7 @@
     >
     <el-button
      v-if="$store.state.admin && click_id && show_switch && $store.state.backend_type == 1"
-     style="margin-left:8px;"
+     style="margin-left:5px;"
      type="primary"
      size="mini"
      @click="handle_refer_curve('set')"
@@ -143,14 +143,14 @@
     >
     <el-button
      v-if="$store.state.admin && click_id && show_switch && !show_xy"
-     style="margin-left:8px;"
+     style="margin-left:5px;"
      type="primary"
      size="mini"
      @click="handle_refer_curve('get')"
      >展示参考</el-button
     >
     <el-button
-     style="margin-left:8px;"
+     style="margin-left:5px;"
      type="primary"
      size="mini"
      v-if="show_xy"
@@ -158,7 +158,7 @@
      >隐藏参考</el-button
     >
     <el-button
-     style="margin-left:8px;"
+     style="margin-left:5px;"
      type="primary"
      size="mini"
      v-if="$store.state.admin && click_id && show_switch && $store.state.backend_type == 1"
@@ -166,13 +166,21 @@
      >取消参考</el-button
     >
     <el-button
-     style="margin-left:8px;"
+     style="margin-left:5px;"
      type="primary"
      size="mini"
      v-if="click_id && !loading"
      @click="get_tem_data"
      >显示温度</el-button
     >
+    <el-button
+     style="margin-left:5px;"
+     type="primary"
+     size="mini"
+     v-if="click_id && !loading"
+     @click="coordinate_state_toggle"
+     >双坐标切换</el-button
+    >
     <!-- 移动x/y轴 -->
     <div class="x_y_val" v-if="show_xy">
      <div class="x_val">
@@ -549,6 +557,7 @@ export default {
    refresh_nodes: null,
    refresh_datas: null,
    is_get_more: false,
+   coordinate_state: false, // false: 双坐标系、true:三坐标系
   }
  },
  watch: {
@@ -1352,6 +1361,7 @@ export default {
    this.show_switch = false
    this.is_query = false
    this.show_xy = false
+   this.coordinate_state = false
    this.click_id = data.id
    this.send_data.tag = data.id + '.resist'
    this.query_hist_confirm.tag = data.id + '.resist'
@@ -1518,6 +1528,11 @@ export default {
      })
    }
   },
+  // 坐标系切换
+  coordinate_state_toggle() {
+   this.coordinate_state = !this.coordinate_state
+   return this.draw_line_curve()
+  },
   // 画图
   draw_line_curve() {
    let date_num = +new Date()
@@ -1538,6 +1553,7 @@ export default {
      if (zh_regex.test(element.name)) element.color = '#6DD5FA' // 天空蓝
     })
    }
+   this.curve_data.coordinate_state = this.coordinate_state
    let option = forceOption(this.curve_data)
    this.myCharts.off('legendselectchanged') // 解除监听legend事件
    this.myCharts.setOption(option, true) // 重新渲染
@@ -1881,8 +1897,8 @@ export default {
    //  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 = [1715961600000, 1716048000000] // 2024年5月18~19号有数据
-   //  this.times = [1715988120000, 1715988540000] // 2024年5月18~19号7点数据
+   this.times = [1715961600000, 1716048000000] // 2024年5月18~19号有数据
+   // this.times = [1715988120000, 1715988540000] // 2024年5月18~19号7点数据
   },
   // 发送浏览记录
   send_record(commit_data) {
@@ -1905,9 +1921,9 @@ export default {
  mounted() {
   this.get_conf_read()
   this.url_is_query()
-  // setTimeout(() => {
-  //  this.search_data = '108'
-  // }, 300)
+  setTimeout(() => {
+   this.search_data = '108'
+  }, 300)
  },
  beforeDestroy() {
   // this.myCharts.clear()