|
|
@ -152,7 +152,7 @@ import * as echarts from "echarts"; |
|
|
|
|
|
|
|
|
// 引入api |
|
|
// 引入api |
|
|
import * as homeApi from '@/api/home' |
|
|
import * as homeApi from '@/api/home' |
|
|
|
|
|
let barChart = null, lineChart = null, pieChart = null; |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
@ -199,22 +199,24 @@ export default { |
|
|
mounted() { |
|
|
mounted() { |
|
|
|
|
|
|
|
|
this.getStat(); |
|
|
this.getStat(); |
|
|
this.btgetdata(); |
|
|
|
|
|
this.getPieData(); |
|
|
this.getPieData(); |
|
|
this.getInfoDatas(); |
|
|
this.getInfoDatas(); |
|
|
this.getGcgNumDatas(); |
|
|
this.getGcgNumDatas(); |
|
|
|
|
|
this.autoTimer0(); |
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
|
|
|
// 加延时器使图像绘制获取元素宽高最新的值、等待接口返回数据 |
|
|
this.home_bar(); |
|
|
this.home_bar(); |
|
|
this.line_zone(); |
|
|
this.line_zone(); |
|
|
this.index_pie1(); |
|
|
this.index_pie1(); |
|
|
}, 1000) |
|
|
}, 1000) |
|
|
|
|
|
|
|
|
this.autoTimer0(); |
|
|
this.getsckdata(); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
autoTimer0(){ |
|
|
autoTimer0(){ |
|
|
let that = this; |
|
|
let that = this; |
|
|
|
|
|
this.btgetdata(); |
|
|
clearInterval(that.timer0); |
|
|
clearInterval(that.timer0); |
|
|
that.timer0 = setInterval(() => { |
|
|
that.timer0 = setInterval(() => { |
|
|
if(this.klselt == 'y'){ |
|
|
if(this.klselt == 'y'){ |
|
|
@ -269,11 +271,12 @@ export default { |
|
|
home_bar() { |
|
|
home_bar() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
var chartDom = document.getElementById("homebar"); |
|
|
var chartDom = document.getElementById("homebar"); |
|
|
var myChart = echarts.init(chartDom); |
|
|
|
|
|
var option; |
|
|
var option; |
|
|
|
|
|
barChart = echarts.init(chartDom); |
|
|
|
|
|
|
|
|
let xData = this.klqsXDatas.slice(-8,this.klqsXDatas.length); |
|
|
function run() { |
|
|
var data = this.klqsDatas.slice(-8,this.klqsDatas.length); |
|
|
let xData = that.klqsXDatas.slice(-8,that.klqsXDatas.length); |
|
|
|
|
|
var data = that.klqsDatas.slice(-8,that.klqsDatas.length); |
|
|
let max=data[0]; |
|
|
let max=data[0]; |
|
|
for (let i = 0; i < data.length; i++) { |
|
|
for (let i = 0; i < data.length; i++) { |
|
|
if (data[i]>max) { |
|
|
if (data[i]>max) { |
|
|
@ -447,58 +450,13 @@ export default { |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
option && myChart.setOption(option); |
|
|
option && barChart.setOption(option); |
|
|
function run(myChart) { |
|
|
|
|
|
if(that.klselt == 'd'){ |
|
|
|
|
|
that.btgetdata(); |
|
|
|
|
|
}else if(that.klselt == 'm'){ |
|
|
|
|
|
that.btgetdata() |
|
|
|
|
|
}else if(that.klselt == 'y'){ |
|
|
|
|
|
that.btgetdata() |
|
|
|
|
|
} |
|
|
} |
|
|
let xData = that.klqsXDatas.slice(-8,that.klqsXDatas.length); |
|
|
run(); |
|
|
let data = that.klqsDatas.slice(-8,that.klqsDatas.length); |
|
|
clearInterval(that.timer1); |
|
|
|
|
|
|
|
|
let max=data[0]; |
|
|
|
|
|
for (let i = 0; i < data.length; i++) { |
|
|
|
|
|
if (data[i]>max) { |
|
|
|
|
|
max = data[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
let dataLenArr = [], dataBGArr = []; |
|
|
|
|
|
data.map(item=>{ |
|
|
|
|
|
dataLenArr.push(1);// 获取和数据一样长度的底部图形数组; |
|
|
|
|
|
dataBGArr.push(max);// 数组最大值做背景柱形 |
|
|
|
|
|
}) |
|
|
|
|
|
myChart.setOption({ |
|
|
|
|
|
xAxis: { |
|
|
|
|
|
data: xData |
|
|
|
|
|
}, |
|
|
|
|
|
series: [ |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'bar', |
|
|
|
|
|
data: data |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'pictorialBar', |
|
|
|
|
|
data: data |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'bar', |
|
|
|
|
|
data: dataBGArr |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'pictorialBar', |
|
|
|
|
|
data: dataBGArr |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
clearInterval(that.timer1);//这个定时器看似多余,但是注释会影响效果,先保留 |
|
|
|
|
|
that.timer1 = setInterval(function () { |
|
|
that.timer1 = setInterval(function () { |
|
|
myChart.clear(); |
|
|
barChart.clear(); |
|
|
option && myChart.setOption(option); |
|
|
run(); |
|
|
run(myChart); |
|
|
|
|
|
}, 5000); |
|
|
}, 5000); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -507,11 +465,12 @@ export default { |
|
|
let that = this; |
|
|
let that = this; |
|
|
var chartDom = document.getElementById("kl-line"); |
|
|
var chartDom = document.getElementById("kl-line"); |
|
|
var option; |
|
|
var option; |
|
|
|
|
|
lineChart = echarts.init(chartDom); |
|
|
|
|
|
|
|
|
|
|
|
function run(){ |
|
|
|
|
|
// 获取新数据-处理--改用ws处理数据 |
|
|
|
|
|
// that.getGcgNumDatas(); |
|
|
|
|
|
|
|
|
function run(myChart){ |
|
|
|
|
|
// 获取新数据-处理 |
|
|
|
|
|
that.getGcgNumDatas(); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
var xData = that.rsqsXData; |
|
|
var xData = that.rsqsXData; |
|
|
var gcolor = ['#ff9acc', '#6666FF', '#FF6600', '#02ff00', '#00ffff', '#fdff00']; |
|
|
var gcolor = ['#ff9acc', '#6666FF', '#FF6600', '#02ff00', '#00ffff', '#fdff00']; |
|
|
|
|
|
|
|
|
@ -667,17 +626,14 @@ export default { |
|
|
}, |
|
|
}, |
|
|
series: series, |
|
|
series: series, |
|
|
} |
|
|
} |
|
|
option && myChart.setOption(option); |
|
|
option && lineChart.setOption(option); |
|
|
}, 200); |
|
|
|
|
|
} |
|
|
} |
|
|
setTimeout(()=>{ |
|
|
run(); |
|
|
var myChart = echarts.init(chartDom); |
|
|
|
|
|
run(myChart); |
|
|
|
|
|
that.timer3 = setInterval(function () { |
|
|
that.timer3 = setInterval(function () { |
|
|
myChart.clear(); |
|
|
lineChart.clear(); |
|
|
run(myChart); |
|
|
run(); |
|
|
}, 3000); |
|
|
}, 3000); |
|
|
}, 200) |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
addNumber(start, end, id) { |
|
|
addNumber(start, end, id) { |
|
|
@ -794,6 +750,8 @@ export default { |
|
|
}, |
|
|
}, |
|
|
index_pie1(){ |
|
|
index_pie1(){ |
|
|
let that = this; |
|
|
let that = this; |
|
|
|
|
|
var pieDom1 = document.getElementById("indexPie1"); |
|
|
|
|
|
pieChart = echarts.init(pieDom1); |
|
|
// var dataP = [ |
|
|
// var dataP = [ |
|
|
// {name: '体育场',value: 5,}, |
|
|
// {name: '体育场',value: 5,}, |
|
|
// {name: '体育馆',value: 20,}, |
|
|
// {name: '体育馆',value: 20,}, |
|
|
@ -818,9 +776,8 @@ export default { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function run(myChart){ |
|
|
function run(){ |
|
|
var dataP = that.dataP; |
|
|
var dataP = that.dataP; |
|
|
// 获取新数据-处理 |
|
|
|
|
|
let color = ['#ff9acc', '#6666ff', '#ff6600', '#02ff00','#00ffff', '#fdff00']; |
|
|
let color = ['#ff9acc', '#6666ff', '#ff6600', '#02ff00','#00ffff', '#fdff00']; |
|
|
let color1=[], color2=[], color3=[]; |
|
|
let color1=[], color2=[], color3=[]; |
|
|
// 设置每层圆环颜色和添加间隔的透明色 |
|
|
// 设置每层圆环颜色和添加间隔的透明色 |
|
|
@ -916,20 +873,41 @@ export default { |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
} |
|
|
} |
|
|
option && myChart.setOption(option); |
|
|
option && pieChart.setOption(option); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 加延时器使图像绘制获取元素宽高最新的值 |
|
|
run(); |
|
|
setTimeout(()=>{ |
|
|
|
|
|
var pieDom1 = document.getElementById("indexPie1"); |
|
|
|
|
|
var myChart = echarts.init(pieDom1); |
|
|
|
|
|
run(myChart); |
|
|
|
|
|
that.timer4 = setInterval(function () { |
|
|
that.timer4 = setInterval(function () { |
|
|
myChart.clear(); |
|
|
pieChart.clear(); |
|
|
that.getPieData(); |
|
|
run(); |
|
|
run(myChart); |
|
|
|
|
|
}, 4000); |
|
|
}, 4000); |
|
|
}, 200) |
|
|
}, |
|
|
|
|
|
// 获取实时数据 |
|
|
|
|
|
getsckdata(){ |
|
|
|
|
|
let that = this; |
|
|
|
|
|
// websocket |
|
|
|
|
|
const ws = new WebSocket("ws://192.168.66.16/rt"); |
|
|
|
|
|
ws.onopen = function() { |
|
|
|
|
|
// console.log("ws connected success!") |
|
|
|
|
|
}; |
|
|
|
|
|
ws.onmessage = (e)=> { |
|
|
|
|
|
var jstr = JSON.parse(e.data) |
|
|
|
|
|
// console.log("11111", jstr, e); |
|
|
|
|
|
if(!jstr){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
const pieData = jstr.realTimeData.data; |
|
|
|
|
|
|
|
|
|
|
|
that.proportionData = [];that.groupNameData=[];that.dataP=[]; |
|
|
|
|
|
pieData.forEach((item) => { |
|
|
|
|
|
that.proportionData.push(item.proportion); |
|
|
|
|
|
that.groupNameData.push(item.groupName); |
|
|
|
|
|
that.dataP.push({ |
|
|
|
|
|
name:item.groupName, |
|
|
|
|
|
value:item.proportion.split('%')[0] |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
}; |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
beforeDestroy(){ |
|
|
beforeDestroy(){ |
|
|
|