修改图表

master
夜笙歌 1 year ago
parent b219e93f71
commit 6b30d765bc

@ -96,6 +96,7 @@ body {
border-radius: 3px; border-radius: 3px;
border: 2px solid #3f65a1; border: 2px solid #3f65a1;
padding: 5%; padding: 5%;
overflow: auto;
} }
.winDiv .title2 { .winDiv .title2 {
@ -117,6 +118,7 @@ body {
border-radius: 3px; border-radius: 3px;
border: 2px solid #3f65a1; border: 2px solid #3f65a1;
padding: 5%; padding: 5%;
overflow: auto;
} }
.status { .status {

@ -88,20 +88,33 @@ $(() => {
}) })
}) })
let chart = null
let chart1 = (el, data) => { let chart1 = (el, data) => {
console.log('chart', chart)
let xData = Object.keys(data?.[0] || {})?.filter(e => e !== 'time') || [] let xData = Object.keys(data?.[0] || {})?.filter(e => e !== 'time') || []
let series = xData.map(e => { let series = xData.map(e => {
let dataA = data?.map(val => val[e]) || []
let isBig = false
dataA.forEach(e => {
if (e > 40) {
isBig = true
}
})
return { return {
name: e, name: e,
type: "line", type: "line",
smooth: true, smooth: true,
symbol: "circle", symbol: "circle",
yAxisIndex: isBig ? 1 : 0,
symbolSize: 5, symbolSize: 5,
showSymbol: false, showSymbol: false,
data: data?.map(val => val[e]) || [], data: dataA,
} }
}) })
let chart = echarts.init(el); if (!chart) {
chart = echarts.init(el)
}
console.log('chart', chart)
let option = { let option = {
tooltip: { tooltip: {
trigger: "axis", trigger: "axis",
@ -175,6 +188,29 @@ let chart1 = (el, data) => {
}, },
}, },
}, },
{
type: "value",
name: "转速n/s",
axisTick: {
show: false,
},
axisLine: {
lineStyle: {
color: "#57617B",
},
},
axisLabel: {
margin: 10,
textStyle: {
fontSize: 14,
},
},
splitLine: {
lineStyle: {
color: "#57617B",
},
},
},
], ],
series: series, series: series,
}; };

@ -101,7 +101,9 @@
params.timeInterval=$('#timeInterval1').val(); params.timeInterval=$('#timeInterval1').val();
$.get(ctx + 'broad/home/queryParamData', params, (e) => { $.get(ctx + 'broad/home/queryParamData', params, (e) => {
if (e.data.length > 0) { if (e.data.length > 0) {
$("#chart1").empty() $('#chart1').remove()
$("#modal1 .centerModal .centerModalInfo").append('<div class="chart1" id="chart1"></div>')
chart = null
chart1(document.getElementById('chart1'), e.data) chart1(document.getElementById('chart1'), e.data)
} else { } else {
$("#chart1").html(`<div style="width: 100%;height: 100%;text-align: center;line-height:35vw;color: #fff ">暂无数据</div>`) $("#chart1").html(`<div style="width: 100%;height: 100%;text-align: center;line-height:35vw;color: #fff ">暂无数据</div>`)

Loading…
Cancel
Save