From f4dec5e5b3a400a6c0fe8cc7fade6b6a01621bfa Mon Sep 17 00:00:00 2001
From: guoshipeng <3194674006@qq.com>
Date: Fri, 18 Aug 2023 10:21:05 +0800
Subject: [PATCH] fix:优化websocket
---
src/views/charts/index.vue | 72 +++++++++++++++++++----------------
1 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/src/views/charts/index.vue b/src/views/charts/index.vue
index 4f4a0b9..e24a91d 100644
--- a/src/views/charts/index.vue
+++ b/src/views/charts/index.vue
@@ -1,5 +1,5 @@
<template>
- <div style="width: 100%;height:100%">
+ <div style="width: 100%; height: 100%">
<div class="topSelect">
<!-- <el-cascader v-model="newMac" :options="options" clearable change-on-select :props="{ checkStrictly: true }" placeholder="������������" /> -->
<el-cascader
@@ -18,8 +18,8 @@
style="margin-left: 20px"
>
<el-option
- v-for="item in newSensor"
- :key="item.value"
+ v-for="(item, index) in newSensor"
+ :key="index"
:label="item.label"
:value="item.value"
/>
@@ -65,7 +65,7 @@
// ���������������������������������������������������������js������������������js���json������������������������������
// ���������import������������������from'������������������';
-import LineChart from '@/components/Echarts/LineChart'
+import LineChart from '@/components/Echarts/LineChart2'
import DatePicker from '@/components/Form/DatePicker'
import MouthPicker from '@/components/Form/MouthPicker'
import HourPicker from '@/components/Form/HourPicker'
@@ -140,6 +140,10 @@
medium: '',
isSelect: false,
options1: [
+ {
+ label: '������������',
+ value: '������������',
+ },
{
label: '���������',
value: '���������',
@@ -168,7 +172,6 @@
}
// ������������������������������������������
this.getSensor()
- console.log(this.newMac1)
},
// ������dataType���������������
select1(nv, ov) {
@@ -184,6 +187,9 @@
} else if (nv === '���������') {
this.dataType = 'HourPicker1'
this.unit = 'hour'
+ } else if (nv === '������������') {
+ this.dataType = 'HourPicker1'
+ this.unit = 'FiveMinute'
} else {
this.dataType = 'CustomPicker'
this.unit = 'hour'
@@ -195,8 +201,7 @@
one === 'a34002' ||
one === 'a21004' ||
one === 'a21026' ||
- one === 'a05024' ||
- one === 'a21001'
+ one === 'a05024'
) {
this.selectyz = '(������:ug/m��)'
} else if (
@@ -224,7 +229,13 @@
this.selectyz = '(������:pcs/0.1L)'
} else if (one === 'a00e13') {
this.selectyz = '(������:db)'
- } else if (one === 'a21028') {
+ } else if (
+ one === 'a21028' ||
+ one === 'a25002' ||
+ one === 'a21001' ||
+ one === 'a25005' ||
+ one === 'a25003'
+ ) {
this.selectyz = '(������:ppm)'
}
},
@@ -248,6 +259,7 @@
methods: {
// ������������
selectData() {
+ console.log(this.newData)
var newLineChartData = {
series: [],
xAxis: [],
@@ -267,49 +279,42 @@
})
.then((res) => {
// console.log('������������������������������')
- console.log(res)
const data = res.data
let lockLength = 0
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < data[i].deviceData.length; j++) {
- if(res.data[0].deviceData.length==1){
- if (lockLength < data[i].deviceData.length) {
+ if (res.data[0].deviceData.length === 1) {
+ if (lockLength < data[i].deviceData.length) {
+ newLineChartData.series.push({
+ data: [],
+ // large: true,
+ name: '',
+ type: 'line',
+ label: {
+ show: true,
+ position: 'top',
+ },
+ })
+ }
+ } else {
newLineChartData.series.push({
data: [],
name: '',
+ // large: true,
type: 'line',
- label: {
- show: true,
- position: 'top',
- },
})
- }
- }
- else if (lockLength < data[i].deviceData.length) {
- newLineChartData.series.push({
- data: [],
- name: '',
- type: 'line',
- label: {
- show: false,
- position: 'top',
- },
- })
- newLineChartData.series[j].name = data[i].deviceData[j].name
- newLineChartData.title.push(data[i].deviceData[j].name)
}
- lockLength++
+ newLineChartData.series[j].name = data[i].deviceData[j].name
+ newLineChartData.title.push(data[i].deviceData[j].name)
newLineChartData.series[j].data.push(
data[i].deviceData[j].sensorValue
)
}
-
-
newLineChartData.xAxis.push(data[i].time)
}
// newLineChartData.title = this.value
this.lineChartData = newLineChartData
- // console.log(newLineChartData, 'newLineChartData')
+ console.log(lineChartData, 'newLineChartData')
})
.catch((err) => {
console.log(err)
@@ -351,6 +356,7 @@
},
// ���������������������������������
getSensor() {
+ this.newSensor = []
// stringMacs.su
// var newMac = this.newMac[this.newMac.length - 1][this.newMac[this.newMac.length - 1].length - 1]
// this.newMac1 = this.newMac[this.newMac.length - 1][this.newMac[this.newMac.length - 1].length - 1]
--
Gitblit v1.8.0