| | |
| | | // 例如:import《组件名称》from'《组件路径》'; |
| | | |
| | | import json from '@/assets/json/sensor.json' |
| | | import requestObj from '@/utils/request' |
| | | import * as echarts from 'echarts' |
| | | // import { parse } from 'path-to-regexp' |
| | | // import LineChart from '@/components/Echarts/LineChart' |
| | | // import draggable from 'vuedraggable' |
| | |
| | | watch: { |
| | | PM2_5Data(val) { |
| | | // console.log('新数据' + val) |
| | | this.myChart = null |
| | | this.drawChart() |
| | | }, |
| | | leftaSide(n, o) { |
| | |
| | | if (this.ws) { |
| | | this.ws.close() |
| | | } |
| | | |
| | | var that = this |
| | | // 拼写参数 |
| | | // var param = this.accountId + '&' + this.orgId + '&' + this.macName |
| | | // var param = this.macName |
| | | // 拼写URL |
| | | var socketUrl |
| | | console.log('requestObj.baseUrl', requestObj.baseUrl) |
| | | if (this.equipment === 'car') { |
| | | socketUrl = 'http://47.99.64.149:8081/api/cruiserWebsocket/' + this.macName |
| | | socketUrl = requestObj.baseUrl + '/cruiserWebsocket/' + this.macName |
| | | // socketUrl = 'http://192.168.0.11:8081/cruiserWebsocket/' + this.macName |
| | | } else { |
| | | socketUrl = 'http://47.99.64.149:8081/api/singleDevice/' + this.macName |
| | | socketUrl = requestObj.baseUrl + '/singleDevice/' + this.macName |
| | | // socketUrl = 'http://192.168.0.11:8081/singleDevice/' + this.macName |
| | | } |
| | | // 替换http为WS |
| | | console.log('socketUrl', socketUrl, this.macNamel) |
| | | socketUrl = socketUrl.replace('https', 'ws').replace('http', 'ws') |
| | | |
| | | this.ws = new WebSocket(socketUrl) |
| | |
| | | const that = this |
| | | var bar_dv = this.$refs.main |
| | | if (bar_dv) { |
| | | that.myChart = this.$echarts.init(bar_dv) |
| | | that.myChart = echarts.init(bar_dv) |
| | | var option = { |
| | | title: { |
| | | left: 'center', |
| | |
| | | bottom: 25 |
| | | }, |
| | | tooltip: { |
| | | // formatter:function(res){ |
| | | // console.log(res,'res'); |
| | | // var result='' |
| | | // var html1='<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#fff;"></span>' |
| | | // result+=res[0].axisValue+"<br/>"+html1+res[0].value |
| | | // return result |
| | | // }, |
| | | formatter: function(res) { |
| | | console.log(res, 'res') |
| | | var result = '' |
| | | var html1 = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:red;"></span>' |
| | | result += res[0].axisValue + '<br/>' + html1 + res[0].value |
| | | return result |
| | | }, |
| | | trigger: 'axis', |
| | | backgroundColor: '#444', // 通过设置rgba调节背景颜色与透明度 |
| | | color: 'red', |
| | | textStyle: { // 悬浮框文字样式 |
| | | color: '#fff', |
| | | fontSize: 12 |
| | | }, |
| | | axisPointer: { |
| | | type: 'cross', |
| | | label: { |
| | |
| | | }, |
| | | series: [ |
| | | { |
| | | // prettier-ignore |
| | | itemStyle: { |
| | | normal: { |
| | | color: '#fff', // 拐点颜色 |
| | | borderColor: 'red', // 拐点边框颜色 |
| | | borderWidth: 3// 拐点边框大小 |
| | | }, |
| | | emphasis: { // 突出效果配置(鼠标置于拐点上时) |
| | | borderColor: '#c00', // 拐点边框颜色 |
| | | borderWidth: 2, // 拐点边框宽度 |
| | | shadowColor: '#c00', // 阴影颜色 |
| | | shadowBlur: 3, // 阴影渐变范围控制 |
| | | color: 'red'// hover拐点颜色定义 |
| | | } |
| | | }, |
| | | symbolSize: 6, |
| | | data: this.PM2_5Data, |
| | | type: 'line', |
| | | label: { |