|
@@ -1,129 +0,0 @@
|
|
|
-<template>
|
|
|
- <div>
|
|
|
- <div style="width:1300px;height:300px"
|
|
|
- id="ReturnCircuit10"></div>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
-import axios from 'axios'
|
|
|
-const echarts = require('echarts')
|
|
|
-export default {
|
|
|
- name: 'ReturnCircuit?circuitId=10',
|
|
|
- data () {
|
|
|
- return {
|
|
|
- intervalId: null, // 定时器
|
|
|
- echart: '',
|
|
|
- q: ['', '', '', '', '', '', '', '', '', ''],
|
|
|
- p: ['', '', '', '', '', '', '', '', '', ''],
|
|
|
- cos: ['', '', '', '', '', '', '', '', '', ''],
|
|
|
- ia: ['', '', '', '', '', '', '', '', '', ''],
|
|
|
- time: ['', '', '', '', '', '', '', '', '', '']
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- getData () {
|
|
|
- axios.get('ReturnCircuit?circuitId=10').then(response => {
|
|
|
- console.log(response.data)
|
|
|
- this.p.shift()
|
|
|
- this.p.push(response.data.p)
|
|
|
-
|
|
|
- this.q.shift()
|
|
|
- this.q.push(response.data.q)
|
|
|
-
|
|
|
- this.cos.shift()
|
|
|
- this.cos.push(response.data.cos)
|
|
|
-
|
|
|
- this.ia.shift()
|
|
|
- this.ia.push(response.data.ia)
|
|
|
-
|
|
|
- this.time.shift()
|
|
|
- this.time.push(response.data.time)
|
|
|
- this.drawChart('ReturnCircuit10')
|
|
|
- }).catch((err) => {
|
|
|
- console.log(err)
|
|
|
- })
|
|
|
- },
|
|
|
- drawChart (id) {
|
|
|
- this.echart = echarts.init(document.getElementById(id))
|
|
|
- this.echart.showLoading()
|
|
|
- this.echart.setOption({
|
|
|
- title: {
|
|
|
- text: '行政办公楼'
|
|
|
- },
|
|
|
- tooltip: {
|
|
|
- trigger: 'axis'
|
|
|
- },
|
|
|
- legend: {},
|
|
|
- grid: {
|
|
|
- left: '3%',
|
|
|
- right: '4%',
|
|
|
- bottom: '3%',
|
|
|
- containLabel: true
|
|
|
- },
|
|
|
- toolbox: {
|
|
|
- feature: {
|
|
|
- saveAsImage: {}
|
|
|
- }
|
|
|
- },
|
|
|
- xAxis: {
|
|
|
- type: 'category',
|
|
|
- boundaryGap: false,
|
|
|
- data: this.time
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- type: 'value'
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: 'Ia',
|
|
|
- type: 'line',
|
|
|
- data: this.Ia
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'P',
|
|
|
- type: 'line',
|
|
|
- data: this.p
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'Q',
|
|
|
- type: 'line',
|
|
|
- data: this.q
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'Cos',
|
|
|
- type: 'line',
|
|
|
- data: this.cos
|
|
|
- }
|
|
|
- ]
|
|
|
- })
|
|
|
- this.echart.hideLoading()
|
|
|
- var _this = this
|
|
|
- window.addEventListener('resize', function () { _this.echart.resize() })
|
|
|
- },
|
|
|
- setTime () {
|
|
|
- this.intervalId = setInterval(() => {
|
|
|
- this.getData()
|
|
|
- }, 2000)
|
|
|
- // 通过$once来监听定时器,在beforeDestroy钩子可以被清除。
|
|
|
- this.$once('hook:beforeDestroy', () => {
|
|
|
- clearInterval(this.intervalId)
|
|
|
- })
|
|
|
- },
|
|
|
- // 计时器停止器
|
|
|
- stop () {
|
|
|
- clearInterval(this.intervalId)// 清除计时器
|
|
|
- this.intervalId = null// 设置为null
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- mounted: function () {
|
|
|
- this.setTime()
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-</script>
|
|
|
-
|
|
|
-<style scoped>
|
|
|
-</style>
|