添加实时刷新

master
夜笙歌 2 months ago
parent 2ccc894561
commit ee46ee16b0

@ -116,6 +116,7 @@
queryDeptTree(); queryDeptTree();
}); });
let time1 = null
function queryDeptTree() { function queryDeptTree() {
var url = ctx + "system/Monitor/treeData?monitorType=" + 20; var url = ctx + "system/Monitor/treeData?monitorType=" + 20;
@ -127,7 +128,6 @@
$.tree.init(options); $.tree.init(options);
function zOnClick(event, treeId, treeNode) { function zOnClick(event, treeId, treeNode) {
console.log(treeNode)
$.post(ctx + 'system/TVibrationsensorData/realTimeMonitor', {sensorId: treeNode.id}, (e) => { $.post(ctx + 'system/TVibrationsensorData/realTimeMonitor', {sensorId: treeNode.id}, (e) => {
if (e.code === 0) { if (e.code === 0) {
let data = e.data || [] let data = e.data || []
@ -207,6 +207,93 @@
}) })
} }
}) })
if(time1){
clearInterval(time1)
time1 = null
}
time1 = setInterval(()=>{
$.post(ctx + 'system/TVibrationsensorData/realTimeMonitor', {sensorId: treeNode.id}, (e) => {
if (e.code === 0) {
let data = e.data || []
$("#chartDivs").html('')
data.forEach((v, k) => {
let html = `
<div class="chartDiv" id="chartDiv">
<div class="title">${v.monitorName}</div>
<div class="time">${v.collectTime}</div>
<div class="chart" id="chart${k}">
</div>
<div class="mileage">
${v.displacement.toString().split('').map(vv => {
return `<div class="num">${vv}</div>`
}).join('')}
</div>
<div class="text">位移(um)</div>
</div>
`
$("#chartDivs").append(html)
let chart = echarts.init(document.getElementById(`chart${k}`))
let option = {
series: [
{
name: 'Pressure',
type: 'gauge',
detail: {
formatter: '{value}',
offsetCenter: [0, '20%'],
// offsetCenter: [0, '-40%'] ,
},
center: ['25%', '50%'],
radius: '90%',
max: Math.max(Math.ceil(v.speed / 100),1 ) * 100,
data: [
{
value: v.speed,
name: '速度(mm/s)',
title: {
offsetCenter: [0, '-20%'],
},
}
]
},
{
name: 'Pressure',
type: 'gauge',
detail: {
fontSize: 20,
formatter: '{value}'
},
center: ['60%', '70%'],
radius: '65%',
axisTick: {
distance: 4
},
pointer: {
length: '50%',
width: 4
},
data: [
{
value: v.temperature,
name: '温度(℃)',
detail: {
fontSize: 12,
},
}
]
},
]
};
chart.setOption(option)
})
}
})
},5*1000)
} }
} }

Loading…
Cancel
Save