修改图表配置

master
suixy 2 weeks ago
parent d6304adfb6
commit a1694891fc

@ -7,7 +7,7 @@
<th:block th:include="include :: datetimepicker-css"/> <th:block th:include="include :: datetimepicker-css"/>
</head> </head>
<style> <style>
.echarts{ .echarts {
width: 49%; width: 49%;
display: inline-block; display: inline-block;
} }
@ -21,12 +21,15 @@
<i class="fa icon-grid"></i> 测控点信息 <i class="fa icon-grid"></i> 测控点信息
</div> </div>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<a class="btn btn-box-tool" href="#" onclick="dept()" title="测控点信息" type="button"><i class="fa fa-edit"></i></a> <a class="btn btn-box-tool" href="#" onclick="dept()" title="测控点信息" type="button"><i
class="fa fa-edit"></i></a>
<button class="btn btn-box-tool" id="btnExpand" style="display:none;" title="展开" type="button"><i <button class="btn btn-box-tool" id="btnExpand" style="display:none;" title="展开" type="button"><i
class="fa fa-chevron-up"></i></button> class="fa fa-chevron-up"></i></button>
<button class="btn btn-box-tool" id="btnCollapse" title="折叠" type="button"><i class="fa fa-chevron-down"></i> <button class="btn btn-box-tool" id="btnCollapse" title="折叠" type="button"><i
class="fa fa-chevron-down"></i>
</button> </button>
<button class="btn btn-box-tool" id="btnRefresh" title="刷新" type="button"><i class="fa fa-refresh"></i></button> <button class="btn btn-box-tool" id="btnRefresh" title="刷新" type="button"><i
class="fa fa-refresh"></i></button>
</div> </div>
</div> </div>
<div class="ui-layout-content"> <div class="ui-layout-content">
@ -44,11 +47,13 @@
<div class="select-list"> <div class="select-list">
<ul> <ul>
<li class="select-time"> <li class="select-time">
<label>采集时间:</label><input class="form-control" id="laydate-demo-3" name="params[beginCollectTime]" <label>采集时间:</label><input class="form-control" id="laydate-demo-3"
name="params[beginCollectTime]"
placeholder="开始时间" placeholder="开始时间"
style="width: 150px" type="text"/> style="width: 150px" type="text"/>
<span>-</span> <span>-</span>
<input class="form-control" id="laydate-demo-4" name="params[endCollectTime]" placeholder="结束时间" <input class="form-control" id="laydate-demo-4" name="params[endCollectTime]"
placeholder="结束时间"
style="width: 150px" style="width: 150px"
type="text"/> type="text"/>
</li> </li>
@ -63,7 +68,7 @@
</form> </form>
</div> </div>
<div class="ibox-content" style="margin-top: 80px;margin-right: 0px;"> <div class="ibox-content" style="margin-top: 80px;margin-right: 0px;">
<div class="echarts" id="echarts-line-chart" style="height: 40vh"></div> <div class="echarts" id="echarts-line-chart" style="height: 80vh;width: 100%"></div>
<div class="echarts" id="echarts-line-chart1" style="height: 40vh"></div> <div class="echarts" id="echarts-line-chart1" style="height: 40vh"></div>
<div class="echarts" id="echarts-line-chart2" style="height: 40vh"></div> <div class="echarts" id="echarts-line-chart2" style="height: 40vh"></div>
<div class="echarts" id="echarts-line-chart3" style="height: 40vh"></div> <div class="echarts" id="echarts-line-chart3" style="height: 40vh"></div>
@ -212,7 +217,7 @@
var formData = new FormData(); var formData = new FormData();
formData.append("sensorId", monitorId); formData.append("sensorId", monitorId);
formData.append("params[beginCollectTime]", $("#laydate-demo-3").val()); formData.append("params[beginCollectTime]", $("#laydate-demo-3").val());
formData.append("params[endCollectTime]",$("#laydate-demo-4").val()); formData.append("params[endCollectTime]", $("#laydate-demo-4").val());
$.ajax({ $.ajax({
url: ctx + "system/TVibrationsensorData/sensorList", url: ctx + "system/TVibrationsensorData/sensorList",
type: 'post', type: 'post',
@ -230,13 +235,11 @@
function design(e) { function design(e) {
console.log(e) console.log(e)
let lineChart = echarts.init(document.getElementById("echarts-line-chart")); let lineChart = echarts.init(document.getElementById("echarts-line-chart"));
let lineChart1 = echarts.init(document.getElementById("echarts-line-chart1"));
let lineChart2 = echarts.init(document.getElementById("echarts-line-chart2"));
let lineChart3 = echarts.init(document.getElementById("echarts-line-chart3"));
lineChart.setOption({ lineChart.setOption({
title: { title: {
text: '温度数据曲线(℃)', text: '温度、速度、位移数据曲线',
left: 'center' left: 'center',
top: 20
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -244,13 +247,16 @@
animation: false animation: false
} }
}, },
grid: {
right: 100,
left: 80
},
legend: { legend: {
data: ['温度'], x: 'center'
left: 10
}, },
dataZoom: [ dataZoom: [
{ {
show: true, show: false,
realtime: true, realtime: true,
start: 0, start: 0,
end: 100, end: 100,
@ -266,158 +272,214 @@
], ],
xAxis: { xAxis: {
type: 'category', type: 'category',
data: e.map(v=>v.collectTime) data: e.map(v => v.collectTime)
}, },
yAxis: { yAxis: [
type: 'value' {
type: 'value',
name: '℃',
axisLine: {
show: true
}
}, },
{
name: 'mm/s',
type: 'value',
axisLine: {
show: true
},
offset: 25,
position: 'left'
},
{
name: 'um',
type: 'value',
axisLine: {
show: true
},
offset: 50
},
// {
// name: 'g',
// type: 'value',
// axisLine: {
// show: true
// }
// },
],
series: [ series: [
{ {
data: e.map(v=>v.temperature), name: '温度',
type: 'line' data: e.map(v => v.temperature),
} type: 'line',
yAxisIndex: 0
},
{
name: '速度',
data: e.map(v => v.speed),
type: 'line',
yAxisIndex: 1
},
{
name: '位移',
data: e.map(v => v.displacement),
type: 'line',
yAxisIndex: 2
},
// {
// name: '加速度',
// data: e.map(v => v.acceleration),
// type: 'line',
// yAxisIndex: 3
// },
] ]
}); });
lineChart1.setOption({
title: {
text: '速度数据曲线(mm/s)',
left: 'center'
},
tooltip: {
trigger: 'axis',
axisPointer: {
animation: false
}
},
legend: {
data: ['速度'],
left: 10
},
dataZoom: [
{
show: true,
realtime: true,
start: 0,
end: 100,
xAxisIndex: 0
},
{
type: 'inside',
realtime: true,
start: 30,
end: 70,
xAxisIndex: 0
}
],
xAxis: {
type: 'category',
data: e.map(v=>v.collectTime)
},
yAxis: {
type: 'value'
},
series: [
{
data: e.map(v=>v.speed),
type: 'line'
}
]
}, true);
lineChart2.setOption({
title: {
text: '位移数据曲线(um)',
left: 'center'
},
tooltip: {
trigger: 'axis',
axisPointer: {
animation: false
}
},
legend: {
data: ['位移'],
left: 10
},
dataZoom: [
{
show: true,
realtime: true,
start: 0,
end: 100,
xAxisIndex: 0
},
{
type: 'inside',
realtime: true,
start: 30,
end: 70,
xAxisIndex: 0
}
],
xAxis: {
type: 'category',
data: e.map(v=>v.collectTime)
},
yAxis: {
type: 'value'
},
series: [
{
data: e.map(v=>v.displacement),
type: 'line'
}
]
}, true);
lineChart3.setOption({
title: {
text: '加速度数据曲线(g)',
left: 'center'
},
tooltip: {
trigger: 'axis',
axisPointer: {
animation: false
}
},
legend: {
data: ['加速度'],
left: 10
},
dataZoom: [
{
show: true,
realtime: true,
start: 0,
end: 100,
xAxisIndex: 0
},
{
type: 'inside',
realtime: true,
start: 30,
end: 70,
xAxisIndex: 0
}
],
xAxis: {
type: 'category',
data: e.map(v=>v.collectTime)
},
yAxis: {
type: 'value'
},
series: [
{
data: e.map(v=>v.acceleration),
type: 'line'
}
]
}, true);
$(window).resize(lineChart.resize); $(window).resize(lineChart.resize);
$(window).resize(lineChart1.resize);
$(window).resize(lineChart2.resize);
$(window).resize(lineChart3.resize); // let lineChart1 = echarts.init(document.getElementById("echarts-line-chart1"));
// let lineChart2 = echarts.init(document.getElementById("echarts-line-chart2"));
// let lineChart3 = echarts.init(document.getElementById("echarts-line-chart3"));
// lineChart1.setOption({
// title: {
// text: '速度数据曲线(mm/s)',
// left: 'center'
// },
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// animation: false
// }
// },
// legend: {
// data: ['速度'],
// left: 10
// },
// dataZoom: [
// {
// show: true,
// realtime: true,
// start: 0,
// end: 100,
// xAxisIndex: 0
// },
// {
// type: 'inside',
// realtime: true,
// start: 30,
// end: 70,
// xAxisIndex: 0
// }
// ],
// xAxis: {
// type: 'category',
// data: e.map(v => v.collectTime)
// },
// yAxis: {
// type: 'value'
// },
// series: [
// {
// data: e.map(v => v.speed),
// type: 'line'
// }
// ]
// }, true);
// lineChart2.setOption({
// title: {
// text: '位移数据曲线(um)',
// left: 'center'
// },
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// animation: false
// }
// },
// legend: {
// data: ['位移'],
// left: 10
// },
// dataZoom: [
// {
// show: true,
// realtime: true,
// start: 0,
// end: 100,
// xAxisIndex: 0
// },
// {
// type: 'inside',
// realtime: true,
// start: 30,
// end: 70,
// xAxisIndex: 0
// }
// ],
// xAxis: {
// type: 'category',
// data: e.map(v => v.collectTime)
// },
// yAxis: {
// type: 'value'
// },
// series: [
// {
// data: e.map(v => v.displacement),
// type: 'line'
// }
// ]
// }, true);
// lineChart3.setOption({
// title: {
// text: '加速度数据曲线(g)',
// left: 'center'
// },
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// animation: false
// }
// },
// legend: {
// data: ['加速度'],
// left: 10
// },
// dataZoom: [
// {
// show: true,
// realtime: true,
// start: 0,
// end: 100,
// xAxisIndex: 0
// },
// {
// type: 'inside',
// realtime: true,
// start: 30,
// end: 70,
// xAxisIndex: 0
// }
// ],
// xAxis: {
// type: 'category',
// data: e.map(v => v.collectTime)
// },
// yAxis: {
// type: 'value'
// },
// series: [
// {
// data: e.map(v => v.acceleration),
// type: 'line'
// }
// ]
// }, true);
// $(window).resize(lineChart1.resize);
// $(window).resize(lineChart2.resize);
// $(window).resize(lineChart3.resize);
} }
</script> </script>
</body> </body>

@ -8,7 +8,7 @@
</head> </head>
<style> <style>
.chartDiv { .chartDiv {
width: 49%; width: 32.5%;
height: 22vw; height: 22vw;
position: relative; position: relative;
display: inline-block; display: inline-block;
@ -37,8 +37,8 @@
.chartDiv .mileage { .chartDiv .mileage {
position: absolute; position: absolute;
top: 70%; top: 74%;
left: 24.2%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
} }
@ -46,7 +46,7 @@
font-size: 1.25vw; font-size: 1.25vw;
position: absolute; position: absolute;
top: 80%; top: 80%;
left: 24.2%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
} }
@ -73,7 +73,8 @@
class="fa fa-chevron-up"></i></button> class="fa fa-chevron-up"></i></button>
<button class="btn btn-box-tool" id="btnCollapse" title="折叠" type="button"><i <button class="btn btn-box-tool" id="btnCollapse" title="折叠" type="button"><i
class="fa fa-chevron-down"></i></button> class="fa fa-chevron-down"></i></button>
<button class="btn btn-box-tool" id="btnRefresh" title="刷新" type="button"><i class="fa fa-refresh"></i> <button class="btn btn-box-tool" id="btnRefresh" title="刷新" type="button"><i
class="fa fa-refresh"></i>
</button> </button>
</div> </div>
</div> </div>
@ -140,11 +141,11 @@
<div class="chart" id="chart${k}"> <div class="chart" id="chart${k}">
</div> </div>
<div class="mileage"> <div class="mileage">
${v.displacement.toString().split('').map(vv => { ${v.temperature.toString().split('').map(vv => {
return `<div class="num">${vv}</div>` return `<div class="num">${vv}</div>`
}).join('')} }).join('')}
</div> </div>
<div class="text">位移(um)</div> <div class="text">温度(℃)</div>
</div> </div>
` `
$("#chartDivs").append(html) $("#chartDivs").append(html)
@ -159,18 +160,28 @@
animation: false, animation: false,
detail: { detail: {
formatter: '{value}', formatter: '{value}',
offsetCenter: [0, '20%'], offsetCenter:
[0, '20%'],
// offsetCenter: [0, '-40%'] , // offsetCenter: [0, '-40%'] ,
}, },
center: ['25%', '50%'], center: ['50%', '50%'],
radius: '90%', radius:
max: Math.max(Math.ceil(v.speed / 100),1 ) * 100, '90%',
data: [ max:
Math.max(Math.ceil(v.speed / 100), 1) * 100,
data:
[
{ {
value: v.speed, value: v.speed,
name: '速度(mm/s)', name: 'mm/s',
title: { title: {
offsetCenter: [0, '-20%'], offsetCenter: ['50%', '65%'],
fontSize: 12,
color: '#000'
},
detail: {
show: false,
fontSize: 12,
}, },
} }
] ]
@ -179,28 +190,28 @@
name: 'Pressure', name: 'Pressure',
type: 'gauge', type: 'gauge',
animation: false, animation: false,
detail: { splitNumber: 4,
fontSize: 20, axisLine: {
formatter: '{value}' show: false
},
center: ['60%', '70%'],
radius: '65%',
axisTick: {
distance: 4
},
pointer: {
length: '50%',
width: 4
}, },
center: ['50%', '50%'],
radius:
'50%',
max: Math.max(Math.ceil(v.displacement / 100), 1) * 100,
data: [ data: [
{ {
value: v.temperature, value: v.displacement,
name: '温度(℃)', name: 'um',
title: {
offsetCenter: ['45%', '55%'],
fontSize: 12,
color: '#000'
},
detail: { detail: {
show: false,
fontSize: 12, fontSize: 12,
}, },
} },
] ]
}, },
] ]
@ -210,12 +221,12 @@
} }
}) })
if(time1){ if (time1) {
clearInterval(time1) clearInterval(time1)
time1 = null time1 = null
} }
time1 = setInterval(()=>{ time1 = setInterval(() => {
$.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 || []
@ -227,12 +238,13 @@
<div class="time">${v.collectTime}</div> <div class="time">${v.collectTime}</div>
<div class="chart" id="chart${k}"> <div class="chart" id="chart${k}">
</div> </div>
<div class="mileage"> <div class="mileage">
${v.displacement.toString().split('').map(vv => { ${v.temperature.toString().split('').map(vv => {
return `<div class="num">${vv}</div>` return `<div class="num">${vv}</div>`
}).join('')} }).join('')}
</div> </div>
<div class="text">位移(um)</div> <div class="text">温度(℃)</div>
</div> </div>
` `
$("#chartDivs").append(html) $("#chartDivs").append(html)
@ -250,42 +262,53 @@
offsetCenter: [0, '20%'], offsetCenter: [0, '20%'],
// offsetCenter: [0, '-40%'] , // offsetCenter: [0, '-40%'] ,
}, },
center: ['25%', '50%'], center: ['50%', '50%'],
radius: '90%', radius: '90%',
max: Math.max(Math.ceil(v.speed / 100),1 ) * 100, max: Math.max(Math.ceil(v.displacement / 100), 1) * 100,
data: [ data: [
{ {
value: v.speed, value: v.displacement,
name: '速度(mm/s)', name: '位移(um)',
title: { title: {
offsetCenter: [0, '-20%'], show: false
},
detail: {
show: false,
fontSize: 12,
},
}, },
}
] ]
}, },
{ {
name: 'Pressure', name: 'Pressure',
type: 'gauge', type: 'gauge',
axisLine: {
show: false
},
animation: false, animation: false,
splitNumber: 4,
detail: { detail: {
fontSize: 20, formatter: '{value}',
formatter: '{value}' offsetCenter:
}, [0, '20%'],
center: ['60%', '70%'], // offsetCenter: [0, '-40%'] ,
radius: '65%', }
axisTick: { ,
center: ['50%', '50%'],
distance: 4 radius:
}, '50%',
pointer: { max:
length: '50%', Math.max(Math.ceil(v.speed / 100), 1) * 100,
width: 4 data:
}, [
data: [
{ {
value: v.temperature, value: v.speed,
name: '温度(℃)', name: '速度(mm/s)',
title: {
show: false
},
detail: { detail: {
show: false,
fontSize: 12, fontSize: 12,
}, },
} }
@ -297,7 +320,7 @@
}) })
} }
}) })
},5*1000) }, 5000 * 1000)
} }
} }

Loading…
Cancel
Save