From c85ea17d45adac17b780992e049685d72168fdda Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期日, 27 四月 2025 14:38:48 +0800
Subject: [PATCH] 工艺文件缓存
---
src/views/equipment/mqtt-show/components/largeAreaChart.vue | 98 +++++++++++++++++++++---------------------------
1 files changed, 43 insertions(+), 55 deletions(-)
diff --git a/src/views/equipment/mqtt-show/components/largeAreaChart.vue b/src/views/equipment/mqtt-show/components/largeAreaChart.vue
index 90ecb43..325ab08 100644
--- a/src/views/equipment/mqtt-show/components/largeAreaChart.vue
+++ b/src/views/equipment/mqtt-show/components/largeAreaChart.vue
@@ -4,8 +4,6 @@
<script>
import * as echarts from 'echarts'
-var myChart = null
-var option = null
export default {
props: {
@@ -25,15 +23,9 @@
data() {
return {
option: {
- tooltip: {
- trigger: 'axis',
- position: function(pt) {
- return [pt[0], '10%']
- }
- },
title: {
left: '5%',
- text: '璁惧鍚嶇О锛�' + this.otherData.deviceName + '\\鍗曚綅锛�' + (this.otherData.unit ? this.otherData.unit : '')
+ text: '璁惧鍚嶇О锛�' + this.otherData.deviceName
},
toolbox: {
right: '5%',
@@ -57,38 +49,39 @@
type: 'value',
boundaryGap: [0, '100%']
},
- dataZoom: [
- {
- type: 'inside',
- start: 0,
- end: 10
- },
- {
- start: 0,
- end: 10
+ tooltip: {
+ trigger: 'axis',
+ formatter: (params) => {
+ var tips = ''
+ const value = params[0].value
+ if (value) {
+ tips =
+ '缂栧彿锛�' +
+ this.otherData.dataStream +
+ '<br />鍙傛暟锛�' +
+ value +
+ '<br />澶囨敞锛�' +
+ (this.otherData.remark ? this.otherData.remark : '') +
+ '<br />鍗曚綅锛�' +
+ (this.otherData.unit ? this.otherData.unit : '') +
+ '<br />鏃堕棿锛�' +
+ params[0].axisValue
+ }
+ return tips
}
- ],
+ },
series: [
{
- name: '鍙傛暟',
+ // name: '鍙傛暟',
type: 'line',
+ label: {
+ normal: {
+ show: true,
+ position: 'top'
+ }
+ },
symbol: 'none',
- sampling: 'lttb',
- itemStyle: {
- color: 'rgb(255, 70, 131)'
- },
- areaStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgb(255, 158, 68)'
- },
- {
- offset: 1,
- color: 'rgb(255, 70, 131)'
- }
- ])
- },
+ areaStyle: { normal: {} },
data: this.seriesData
}
]
@@ -96,33 +89,28 @@
}
},
mounted() {
- myChart = echarts.init(this.$refs.myChart)
- option = this.makeOption()
+ // 姝g‘浣跨敤 this 鏉ュ畾涔� myChart 涓虹粍浠跺疄渚嬬殑鍙橀噺
+ this.myChart = echarts.init(this.$refs.myChart)
this.initDrag()
},
methods: {
- makeOption() {},
initDrag() {
- myChart.setOption((option = this.option), true)
+ this.myChart.setOption(this.option)
- // 椤甸潰鍙戠敓鍙樺寲tree涔熸敼鍙�
+ // 椤甸潰鍙戠敓鍙樺寲 tree 涔熸敼鍙�
window.addEventListener('resize', () => {
- if (myChart) myChart.resize()
+ if (this.myChart) this.myChart.resize()
})
+ },
+ refreshData(seriesData, xAxisData) {
+ // 鍒锋柊鏁版嵁
+ const refreshOption = this.myChart.getOption()
+ refreshOption.series[0].data = seriesData
+ refreshOption.xAxis[0].data = xAxisData
+ // 浣跨敤 Promise 鍖呰 setOption 浣垮叾鎴愪负寮傛鎿嶄綔
+ this.myChart.setOption(refreshOption, true)
}
- },
- // watch: {
- // yAxisMonth: {
- // handler(newVal) {
- // console.log(`output->myChart`,myChart)
- // setTimeout(()=>{
- // myChart.setOption((option = this.option), true)
- // },100)
-
- // },
- // deep: true
- // }
- // }
+ }
}
</script>
--
Gitblit v1.9.3