418 lines
6.9 KiB
Vue
Raw Normal View History

2023-09-28 15:02:13 +08:00
<template>
<Card title="生产质量统计">
<div class="load-top-right">
<div id="materialStatisticsT" style="width: 100%; height: 100%"></div>
</div>
</Card>
</template>
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import * as echarts from "echarts";
import Card from "@/components/card.vue";
import { GlobalStore } from "@/stores";
import { noop } from "@vueuse/core";
let rangeTime = ref("" as any);
let dataList = ref([
{
value: 75,
show: true,
name: "正常",
itemStyle: {
normal: {
color: "#82FBEA",
borderWidth: 20
}
}
},
{
value: 63,
show: true,
name: "初级超标",
itemStyle: {
normal: {
color: "#e8c15c",
borderWidth: 20
}
}
},
{
value: 30,
show: true,
name: "中级超标",
itemStyle: {
normal: {
color: "orange"
}
}
},
{
value: 30,
show: true,
name: "高级超标",
itemStyle: {
normal: {
color: "#eb6266"
}
}
},
// {
// value: 30,
// show: true,
// name: "用电材料",
// itemStyle: {
// normal: {
// color: "#EC6266"
// }
// }
// },
// {
// value: 30,
// show: true,
// name: "木材",
// itemStyle: {
// normal: {
// color: "#81F279"
// }
// }
// }
]);
function Pie() {
let dataArr = [];
for (var i = 0; i < 150; i++) {
if (i % 2 === 0) {
dataArr.push({
name: (i + 1).toString(),
value: 10,
itemStyle: {
normal: {
color: "#7cf4f1",
borderWidth: 0,
borderColor: "#7f6546"
}
}
});
} else {
dataArr.push({
name: (i + 1).toString(),
value: 10,
itemStyle: {
normal: {
color: "rgba(0,0,0,0)",
borderWidth: 0,
borderColor: "rgba(0,0,0,0)"
}
}
});
}
}
return dataArr;
}
onMounted(() => {
drawEchart();
});
function drawEchart() {
let max = 0;
dataList.value.map(item => {
max = max + item.value;
});
let echartsTest = echarts.init(document.getElementById("materialStatisticsT"));
let option = {
tooltip: {
trigger: "item"
},
title: {
text: max,
subtext: "数量统计",
x: "45%",
y: "28%",
textStyle: {
color: "#fff",
fontSize: 24,
fontWeight: "normal",
textAlign: "center",
fontFamily: "sadigitalNumber"
},
subtextStyle: {
color: "#ccc",
fontSize: 14,
lineHeight: 40,
fontWeight: "normal",
textAlign: "center"
}
},
legend: {
selectedMode: false, // 取消图例上的点击事件
icon: "rect",
type: "plain",
left: "25%",
bottom: "5%",
itemGap: 20,
itemWidth: 10, // 设置宽度
itemHeight: 10, // 设置高度
symbolKeepAspect: false,
textStyle: {
color: "#000",
rich: {
name: {
width: 100,
verticalAlign: "left",
fontSize: 14,
color: "#FFFFFF"
},
value: {
width: 70,
fontSize: 14,
color: "#FFFFFF"
}
}
},
data: dataList.value.map(item => {
if (item.show) {
return item.name;
}
}),
formatter: function (data) {
if (dataList.value && dataList.value.length) {
for (var i = 0; i < dataList.value.length; i++) {
if (data === dataList.value[i].name) {
var value = dataList.value[i].value;
var percentage = value + "%";
return "{name| " + data + "} {gap| }" + "{value| " + value + " " + percentage + "}";
}
}
}
}
},
series: [
// 外侧光线
{
name: "",
type: "gauge",
center: ["52%", "35%"],
radius: "55%",
startAngle: 235,
endAngle: -50,
min: 0,
max: 100,
axisLine: {
show: true,
lineStyle: {
width: 2,
color: [
[
100 / 100,
new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{
offset: 0,
color: "#526277"
},
{
offset: 0.25,
color: "rgba(4, 14, 54,0.4)"
},
{
offset: 0.7,
color: "rgba(4, 14, 54,0.4)"
},
{
offset: 1,
color: "#526277"
}
])
],
[1, "rgba(255,255,255,0)"]
]
}
},
axisTick: {
show: 0
},
splitLine: {
show: 0
},
axisLabel: {
show: 0
},
pointer: {
show: 0
},
detail: {
show: 0
}
},
{
name: "",
type: "gauge",
center: ["52%", "35%"],
radius: "47%",
startAngle: 245,
endAngle: -115,
min: 0,
max: 100,
axisLine: {
show: true,
lineStyle: {
width: 2,
color: [
[
200 / 100,
new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{
offset: 0.8,
color: "#52bef0"
},
{
offset: 0.5,
color: "#13356b"
}
])
],
[1, "rgba(255,255,255,0)"]
]
}
},
axisTick: {
show: 0
},
splitLine: {
show: 0
},
axisLabel: {
show: 0
},
pointer: {
show: 0
},
detail: {
show: 0
}
},
{
name: "",
type: "pie",
radius: ["37%", "40%"],
center: ["52%", "35%"],
hoverAnimation: true,
itemStyle: {
borderRadius: 10,
borderWidth: 10
},
label: {
show: false,
position: "center"
},
emphasis: {
label: {
show: false
}
},
labelLine: {
show: false
},
data: dataList.value
},
{
type: "pie",
radius: ["32%", "33%"],
center: ["52%", "35%"],
label: {
show: false
},
data: Pie()
}
]
};
echartsTest.setOption(option, true);
}
</script>
<style lang="scss" scoped>
.load-top-right {
width: 100%;
height: 100%;
position: relative;
}
.num {
width: 66px;
text-align: center;
font-family: sadigitalNumber;
font-size: calc(100vw * 24 / 1920);
color: #fff;
position: absolute;
top: 45%;
left: 18%;
z-index: 9;
}
// .styleImg {
// left: 6%;
// top: 17%;
// width: 40%;
// position: absolute;
// height: 60%;
// background: url("@/assets/images/dustNoise/motionEffect.webp") no-repeat;
// background-size: cover;
// }
.select-right {
width: 35%;
display: flex;
position: absolute;
z-index: 10;
color: #fff;
font-size: 10px;
text-align: center;
line-height: 20px;
right: -1%;
top: 5%;
.selected {
height: 5%;
background: url("@/assets/images/dustNoise/rightImg2.png") no-repeat;
background-size: 100% 100%;
cursor: pointer;
}
.day {
padding: 0 6%;
margin-right: 5%;
z-index: 99;
}
.week {
padding: 0 6%;
margin-right: 5%;
z-index: 99;
}
.month {
padding: 0 6%;
z-index: 99;
}
.active {
background: url("@/assets/images/dustNoise/rightImg.png") no-repeat;
background-size: 100% 100%;
}
}
.time {
position: absolute;
z-index: 999;
left: 37%;
margin-top: -18%;
}
::v-deep .el-input__wrapper {
width: 85%;
height: 0%;
background: #0d2956;
}
::v-deep .el-range-separator {
color: #ccc;
font-size: 10px;
}
::v-deep .el-range-input {
color: #ccc;
font-size: 10px;
}
</style>