You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
<template>
|
|
<div class="chart LineChart">
|
|
<div
|
|
v-if="datalength.length > 0"
|
|
class="chart LineChart"
|
|
ref="LineChartRef"
|
|
/>
|
|
<Empty v-else text="暂无数据..."></Empty>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import * as echarts from "echarts";
|
|
import { lineChartOption } from "./chart";
|
|
import { deviceStatusList } from "@/api/equipment/type/api.js";
|
|
import { months } from "moment/moment";
|
|
|
|
export default {
|
|
name: "LineChart",
|
|
props: {
|
|
productId: {
|
|
type: Number,
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
datalength: {},
|
|
};
|
|
},
|
|
methods: {
|
|
// 根据id获取在线率统计数据
|
|
getDeviceStatusList() {
|
|
return deviceStatusList(this.productId).then((res) => {
|
|
this.datalength = Object.keys(res.data);
|
|
lineChartOption.xAxis.data = Object.keys(res.data);
|
|
lineChartOption.series[0].data = Object.values(res.data);
|
|
});
|
|
},
|
|
},
|
|
async mounted() {
|
|
await this.getDeviceStatusList();
|
|
const chartIns = echarts.init(this.$refs.LineChartRef);
|
|
chartIns.setOption(lineChartOption);
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.LineChart {
|
|
flex: 1;
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
|