ggfwjsc/src/view/echarts_hygiene/eP4.vue

170 lines
3.8 KiB
Vue
Raw Normal View History

2024-04-17 15:25:25 +08:00
<template>
2024-05-24 15:32:07 +08:00
<div ref="chart" style="width: 100%; height: 100%"></div>
2024-04-17 15:25:25 +08:00
</template>
<script setup>
2024-06-06 11:07:37 +08:00
import {
onBeforeMount,
ref,
reactive,
defineProps,
watch,
nextTick,
} from "vue";
2024-04-17 15:25:25 +08:00
// 局部引入echarts核心模块
import * as echarts from "echarts";
2024-06-06 11:07:37 +08:00
const props = defineProps({
list: {
type: Array,
default: () => {
return [];
},
},
});
2024-04-17 15:25:25 +08:00
const chart = ref(); // 创建DOM引用
2024-06-06 11:07:37 +08:00
const data = reactive({
list: 60,
option: {},
});
2024-04-17 15:25:25 +08:00
2024-06-06 11:07:37 +08:00
const getOption = () => {
data.option = {
series: [
// 外圈背景
{
type: "pie",
center: ["55%", "55%"],
radius: ["70%", "90%"],
hoverAnimation: false,
clockWise: false,
// startAngle: 180,
// endAngle: 360,
itemStyle: {
normal: {
borderWidth: 1,
borderColor: "rgba(193, 229, 255, .1)",
color: new echarts.graphic.LinearGradient(1, 1, 1, 0, [
{
offset: 1,
color: "rgba(127, 242, 255, .2)",
},
{
offset: 0,
color: "rgba(109, 195, 255, 0)",
},
]),
},
2024-04-17 15:25:25 +08:00
},
2024-06-06 11:07:37 +08:00
tooltip: {
show: false,
},
label: {
show: false,
},
data: [100],
2024-05-24 15:32:07 +08:00
},
2024-06-06 11:07:37 +08:00
/*内心原型图,展示整体数据概览*/
{
// name: "pie",
type: "pie",
roundCap: true,
clockWise: true,
radius: ["50%", "70%"],
center: ["55%", "55%"],
startAngle: 180,
labelLine: {
show: false,
},
hoverAnimation: false,
data: [
{
value: data.list,
label: {
normal: {
position: "center",
show: true,
textStyle: {
fontSize: "24",
fontWeight: "normal",
color: "#fff",
fontSize: 16,
lineHeight: 30,
rich: {
cell: {
fontSize: "24",
fontWeight: "normal",
color: "#fff",
},
text: {
fontSize: 16,
fontFamily: "FZLanTingHeiS-L-GB",
color: "#fff",
},
2024-05-24 15:32:07 +08:00
},
},
},
2024-04-17 15:25:25 +08:00
},
2024-06-06 11:07:37 +08:00
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 1, 1, 0, [
{
offset: 0,
color: "rgba(0, 255, 250, 0.29)",
},
{
offset: 0.5,
color: "rgba(0, 255, 250, 0.8)",
},
{
offset: 1,
color: "rgba(0, 255, 250, 1)",
},
]),
shadowColor: "rgba(1,1,1,0.5)",
shadowBlur: 1,
},
},
2024-05-24 15:32:07 +08:00
},
2024-06-06 11:07:37 +08:00
{
value: 100 - data.list,
name: "",
itemStyle: {
normal: {
color: "#095b9b", // 未完成的圆环的颜色
label: {
show: false,
2024-05-24 15:32:07 +08:00
},
2024-06-06 11:07:37 +08:00
labelLine: {
show: false,
2024-04-17 15:25:25 +08:00
},
2024-05-24 15:32:07 +08:00
},
2024-06-06 11:07:37 +08:00
emphasis: {
color: "#095b9b", // 未完成的圆环的颜色
2024-05-24 15:32:07 +08:00
},
},
},
2024-06-06 11:07:37 +08:00
],
},
],
};
2024-04-17 15:25:25 +08:00
};
2024-06-06 11:07:37 +08:00
const setChart = () => {
2024-05-24 15:32:07 +08:00
var myChart = echarts.init(chart.value);
2024-06-06 11:07:37 +08:00
myChart.setOption(data.option);
};
2024-04-17 15:25:25 +08:00
2024-06-06 11:07:37 +08:00
// 使用生命钩子
onBeforeMount(() => {
setTimeout(() => {
data.list = props.list;
getOption();
setChart();
}, 600);
2024-04-17 15:25:25 +08:00
});
</script>
2024-05-24 15:32:07 +08:00
<style scoped></style>