|
@@ -1,36 +1,115 @@
|
|
|
<template>
|
|
|
- <div ref="distion" style="width: 100%; height: 100%"></div>
|
|
|
+ <div ref="barChart" style="width: 100%; height: 100%"></div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import * as echarts from "echarts";
|
|
|
-
|
|
|
+import api from "@/api/Overview/index";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
export default {
|
|
|
props: {},
|
|
|
data() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ chart:[],
|
|
|
+ itemStyle: [
|
|
|
+ {
|
|
|
+ normal: {
|
|
|
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: "#00FBE0",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: "#00FBE0",
|
|
|
+ },
|
|
|
+ ]),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ normal: {
|
|
|
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: "#FF8A0D",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: "#FF8A0D",
|
|
|
+ },
|
|
|
+ ]),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ //折线拐点标志的样式
|
|
|
+ color: "#fff",
|
|
|
+ borderColor: "#44A9FF",
|
|
|
+ width: 2,
|
|
|
+ shadowColor: "#44A9FF",
|
|
|
+ shadowBlur: 2,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
},
|
|
|
-
|
|
|
mounted() {
|
|
|
this.$nextTick(() => {
|
|
|
- this.initChart();
|
|
|
+ this.demandIco();
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
beforeUnmount() {
|
|
|
window.removeEventListener("resize", this.chart);
|
|
|
},
|
|
|
-
|
|
|
+ watch: {
|
|
|
+ "$store.state.siteId"() {
|
|
|
+ this.demandIco();
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ demandIco() {
|
|
|
+ api
|
|
|
+ .demandIco({
|
|
|
+ siteId: this.$store.state.siteId,
|
|
|
+ })
|
|
|
+ .then((requset) => {
|
|
|
+ if (requset.status === "SUCCESS") {
|
|
|
+ this.initChart(requset.data);
|
|
|
+ } else {
|
|
|
+ ElMessage.success({
|
|
|
+ message: requset.msg,
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
//次数分布折线图
|
|
|
- initChart() {
|
|
|
- var chart = echarts.init(this.$refs.distion);
|
|
|
+ initChart(data) {
|
|
|
+ var chart = echarts.init(this.$refs.barChart);
|
|
|
var option;
|
|
|
+ var dataAll = [];
|
|
|
+ var dataName = [];
|
|
|
|
|
|
- var arr = new Array();
|
|
|
- for (var i = 0; i < 31; i++) {
|
|
|
- arr.push(i);
|
|
|
- }
|
|
|
-
|
|
|
+ data.map((val, ind) => {
|
|
|
+ dataName.push(val.name);
|
|
|
+ dataAll.push({
|
|
|
+ name: val.name,
|
|
|
+ type: ind == 2 ? "line" : "bar",
|
|
|
+ barWidth: "4",
|
|
|
+ itemStyle: this.itemStyle[ind],
|
|
|
+ data: val.list,
|
|
|
+ yAxisIndex: ind == 2 ? 1 : 0,
|
|
|
+ showAllSymbol: ind == 2 ? true : false,
|
|
|
+ symbol: ind == 2 ? "circle" : "",
|
|
|
+ symbolSize: ind == 2 ? 6 : 0,
|
|
|
+ lineStyle:
|
|
|
+ ind == 2
|
|
|
+ ? {
|
|
|
+ color: "#44A9FF",
|
|
|
+ width: 2,
|
|
|
+ shadowBlur: 2,
|
|
|
+ }
|
|
|
+ : {},
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
option = {
|
|
|
tooltip: {
|
|
|
trigger: "axis",
|
|
@@ -48,8 +127,7 @@ export default {
|
|
|
bottom: "22%",
|
|
|
},
|
|
|
legend: {
|
|
|
- // data: ["昨日总人数", "今日实时人数", "昨日使用率"],
|
|
|
- data: ["最小值", "最大值", "平均值"],
|
|
|
+ data: dataName,
|
|
|
bottom: "0%",
|
|
|
textStyle: {
|
|
|
color: "#fff",
|
|
@@ -59,7 +137,7 @@ export default {
|
|
|
itemHeight: 10,
|
|
|
},
|
|
|
xAxis: {
|
|
|
- data: arr,
|
|
|
+ data: data[0].listDate,
|
|
|
axisLine: {
|
|
|
show: true, //隐藏X轴轴线
|
|
|
lineStyle: {
|
|
@@ -93,7 +171,7 @@ export default {
|
|
|
show: true,
|
|
|
lineStyle: {
|
|
|
width: 1,
|
|
|
- color: "rgba(255,255,255,0.1)",
|
|
|
+ color: "rgba(255,255,255,0.1)",
|
|
|
},
|
|
|
},
|
|
|
axisTick: {
|
|
@@ -114,103 +192,41 @@ export default {
|
|
|
type: "value",
|
|
|
name: "平均值",
|
|
|
nameTextStyle: {
|
|
|
- color: "#fff",
|
|
|
- fontSize: 10
|
|
|
+ color: "#fff",
|
|
|
+ fontSize: 10,
|
|
|
},
|
|
|
position: "right",
|
|
|
splitLine: {
|
|
|
- show: false
|
|
|
+ show: false,
|
|
|
},
|
|
|
axisTick: {
|
|
|
- show: false
|
|
|
+ show: false,
|
|
|
},
|
|
|
axisLine: {
|
|
|
- show: false,
|
|
|
- lineStyle: {
|
|
|
- color: "#396A87",
|
|
|
- width: 2
|
|
|
- }
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- show: true,
|
|
|
- formatter: "{value} %", //右侧Y轴文字显示
|
|
|
- textStyle: {
|
|
|
- color: "#fff",
|
|
|
- fontSize: 10
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- ],
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: "最小值",
|
|
|
- type: "bar",
|
|
|
- barWidth: "4",
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
- {
|
|
|
- offset: 0,
|
|
|
- color: "#00FBE0",
|
|
|
- },
|
|
|
- {
|
|
|
- offset: 1,
|
|
|
- color: "#00FBE0",
|
|
|
- },
|
|
|
- ]),
|
|
|
+ show: false,
|
|
|
+ lineStyle: {
|
|
|
+ color: "#396A87",
|
|
|
+ width: 2,
|
|
|
},
|
|
|
},
|
|
|
- data: [0.24, 0.45, 0.43, 0.35, 0.76, 0.154, 0.86, 0.42, 0.68, 0.97, 0.24, 0.34,0.45, 0.45, 0.43, 0.75, 0.85, 0.35, 0.76, 0.154, 0.86, 0.42, 0.68, 0.97,0.43, 0.35, 0.76, 0.154, 0.86, 0.42, 0.68, 0.97,],
|
|
|
- },
|
|
|
- {
|
|
|
- name: "最大值",
|
|
|
- type: "bar",
|
|
|
- barWidth: "4",
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
- {
|
|
|
- offset: 0,
|
|
|
- color: "#FF8A0D",
|
|
|
- },
|
|
|
- {
|
|
|
- offset: 1,
|
|
|
- color: "#FF8A0D",
|
|
|
- },
|
|
|
- ]),
|
|
|
+ axisLabel: {
|
|
|
+ show: true,
|
|
|
+ formatter: "{value} %", //右侧Y轴文字显示
|
|
|
+ textStyle: {
|
|
|
+ color: "#fff",
|
|
|
+ fontSize: 10,
|
|
|
},
|
|
|
},
|
|
|
- data: [ 0.133, 0.23, 0.114, 0.67, 0.89, 0.35, 0.67, 0.96, 0.90, 0.46, 0.75, 0.85, 0.75, 0.85,0.45, 0.43, 0.35, 0.76, 0.154, 0.86, 0.42, 0.68, 0.97,0.45, 0.43, 0.35, 0.76, 0.154, 0.86, 0.42, 0.68, 0.97,],
|
|
|
- },
|
|
|
- {
|
|
|
- name: "平均值",
|
|
|
- type: "line",
|
|
|
- yAxisIndex: 1, //使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用
|
|
|
- showAllSymbol: true, //显示所有图形。
|
|
|
- symbol: "circle", //标记的图形为实心圆
|
|
|
- symbolSize: 6, //标记的大小
|
|
|
- itemStyle: {
|
|
|
- //折线拐点标志的样式
|
|
|
- color: "#fff",
|
|
|
- borderColor: "#44A9FF",
|
|
|
- width: 2,
|
|
|
- shadowColor: "#44A9FF",
|
|
|
- shadowBlur: 2,
|
|
|
- },
|
|
|
- lineStyle: {
|
|
|
- color: "#44A9FF",
|
|
|
- width: 2,
|
|
|
- shadowBlur: 2,
|
|
|
- },
|
|
|
- data: [4.2, 3.5, 2.9, 7.8, 2, 3, 4.2, 3.5, 2.9, 7.8, 2, 3, 7.8, 2, 3, 4.2, 3.5, 2.9, 7.8, 2, 3, 7.8, 2, 3, 4.2, 3.5, 2.9, 7.8, 2, 3,2],
|
|
|
},
|
|
|
],
|
|
|
+ series: dataAll,
|
|
|
};
|
|
|
|
|
|
- chart.setOption(option);
|
|
|
+ chart.setOption(option, true);
|
|
|
window.addEventListener("resize", () => {
|
|
|
chart.resize();
|
|
|
});
|
|
|
+ this.chart = chart
|
|
|
},
|
|
|
},
|
|
|
};
|