优化水房大屏

This commit is contained in:
hzz 2023-06-19 17:45:24 +08:00
parent 54792bd244
commit 30257eab2c

View File

@ -93,8 +93,11 @@ let mathList = reactive([
{ color: '#EE6666', name: '用电量', max: 100, min: 0, avg: 50 } { color: '#EE6666', name: '用电量', max: 100, min: 0, avg: 50 }
]) ])
function init() { function initChart(date,inChart, outChart, currentChart) {
chart = proxy.$echarts.init(mainChart.value, 'dark'); if (!chart) {
chart = proxy.$echarts.init(mainChart.value, 'dark');
}
let option = { let option = {
// title: { // title: {
// text: '', // text: '',
@ -115,15 +118,7 @@ function init() {
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: [ data: date
"2023-06-11",
"2023-06-12",
"2023-06-13",
"2023-06-14",
"2023-06-15",
"2023-06-16",
"2023-06-17"
]
}, },
yAxis: [ yAxis: [
{ {
@ -134,7 +129,6 @@ function init() {
type: 'value', type: 'value',
name: '电量', name: '电量',
position: 'right', position: 'right',
alignTicks: true,
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
@ -148,21 +142,21 @@ function init() {
name: '进水量', name: '进水量',
type: 'line', type: 'line',
smooth: true, smooth: true,
data: [0, 2, 1, 1, 2, 0, 1] data: inChart
}, },
{ {
name: '出水量', name: '出水量',
type: 'line', type: 'line',
smooth: true, smooth: true,
yAxisIndex: 0, yAxisIndex: 0,
data: [0, 0, 0, 0, 0, 0, 0] data: outChart
}, },
{ {
name: '用电量', name: '用电量',
type: 'line', type: 'line',
smooth: true, smooth: true,
yAxisIndex: 1, yAxisIndex: 1,
data: [1.0907, 0.595, 0.9884, 1.625, 1.7888, 1.9918, 1.6647] data: currentChart
} }
] ]
}; };
@ -180,28 +174,8 @@ async function getWaterFlowInfoFun() {
allData.currentCount = data.currentCount allData.currentCount = data.currentCount
allData.xl = data.xl.toFixed(1) allData.xl = data.xl.toFixed(1)
allData.xy = data.xy.toFixed(1) allData.xy = data.xy.toFixed(1)
chart.setOption({ initChart(data.date, data.inChart, data.outChart, data.currentChart)
xAxis: { data: data.date },
series: [
{
name: '进水量',
type: 'line',
data: data.inChart
},
{
name: '出水量',
type: 'line',
yAxisIndex: 0,
data: data.outChart
},
{
name: '用电量',
type: 'line',
yAxisIndex: 1,
data: data.currentChart
}
]
})
mathList[0].max = data.math.WaterInflow.max mathList[0].max = data.math.WaterInflow.max
mathList[0].min = data.math.WaterInflow.min mathList[0].min = data.math.WaterInflow.min
mathList[0].avg = data.math.WaterInflow.avg mathList[0].avg = data.math.WaterInflow.avg
@ -218,7 +192,6 @@ async function getWaterFlowInfoFun() {
} }
onMounted(() => { onMounted(() => {
init()
getWaterFlowInfoFun() getWaterFlowInfoFun()
}) })
</script> </script>