Files
emsfront/src/views/ems/dzjk/sbjk/ssyx/PocpjwdChart.vue

111 lines
2.5 KiB
Vue
Raw Normal View History

2025-06-18 01:01:17 +08:00
<template>
2025-09-27 14:50:20 +08:00
<el-card
shadow="always"
class="common-card-container common-card-container-body-no-padding"
>
2025-06-18 01:01:17 +08:00
<div slot="header">
2025-09-27 14:50:20 +08:00
<span class="card-title">PCS最高温度</span>
2025-06-18 01:01:17 +08:00
</div>
2025-09-27 14:50:20 +08:00
<div style="height: 360px" id="pocpjwdChart" />
2025-06-18 01:01:17 +08:00
</el-card>
</template>
<style scoped lang="scss"></style>
<script>
2025-09-27 14:50:20 +08:00
import * as echarts from "echarts";
import resize from "@/mixins/ems/resize";
import { formatDate } from "@/filters/ems";
import { pcsMaxTemp } from "@/api/ems/dzjk";
2025-06-18 01:01:17 +08:00
export default {
mixins: [resize],
data() {
return {
2025-09-27 14:50:20 +08:00
chart: null,
};
2025-06-18 01:01:17 +08:00
},
mounted() {
2025-09-27 14:50:20 +08:00
this.chart = echarts.init(document.querySelector("#pocpjwdChart"));
2025-06-18 01:01:17 +08:00
},
beforeDestroy() {
if (!this.chart) {
2025-09-27 14:50:20 +08:00
return;
2025-06-18 01:01:17 +08:00
}
2025-09-27 14:50:20 +08:00
this.chart.dispose();
this.chart = null;
2025-06-18 01:01:17 +08:00
},
methods: {
2025-11-25 17:56:12 +08:00
init(siteId,timeRange) {
2025-09-27 14:50:20 +08:00
this.chart.showLoading();
const x = [];
const data = [];
2025-11-25 17:56:12 +08:00
const [startTime='', endTime=''] = timeRange;
pcsMaxTemp(siteId,startTime,endTime)
2025-09-27 14:50:20 +08:00
.then((response) => {
this.setOption(response?.data?.pcsMaxTempList || []);
})
2025-09-27 14:50:20 +08:00
.finally(() => {
this.chart.hideLoading();
});
2025-06-18 01:01:17 +08:00
},
2025-09-27 14:50:20 +08:00
setOption(data) {
let xdata = [],
series = [];
data.forEach((element, index) => {
if (index === 0) {
xdata = (element.maxTempVoList || []).map((i) => i.createDate);
}
series.push({
type: "line",
name: `${element.deviceId}最高温度`,
areaStyle: {
// color:'#FFBD00'
},
data: (element.maxTempVoList || []).map((i) => i.temp),
});
});
2025-06-18 01:01:17 +08:00
this.chart.setOption({
2025-09-27 14:50:20 +08:00
legend: {
left: "center",
top: "5",
itemWidth: 10,
itemHeight: 5,
textStyle: {
fontSize: 9,
},
2025-06-18 01:01:17 +08:00
},
grid: {
2025-09-27 14:50:20 +08:00
containLabel: true,
},
tooltip: {
trigger: "axis",
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
},
2025-09-27 14:50:20 +08:00
textStyle: {
color: "#333333",
2025-06-18 01:01:17 +08:00
},
2025-09-27 14:50:20 +08:00
xAxis: { type: "category", data: xdata },
2025-06-18 01:01:17 +08:00
yAxis: {
2025-09-27 14:50:20 +08:00
type: "value",
2025-06-18 01:01:17 +08:00
},
dataZoom: [
{
2025-09-27 14:50:20 +08:00
type: "inside",
start: 0,
2025-09-27 14:50:20 +08:00
end: 100,
},
{
start: 0,
2025-09-27 14:50:20 +08:00
end: 100,
},
],
2025-09-27 14:50:20 +08:00
series,
});
},
},
};
2025-06-18 01:01:17 +08:00
</script>