2023-06-12 09:06:00 +00:00
|
|
|
<!--
|
|
|
|
* @FilePath: \code\gitscreenFront\src\views\Mechanics\components\ringChart.vue
|
|
|
|
* @Author: 王路平
|
|
|
|
* @文件版本: V1.0.0
|
|
|
|
* @Date: 2023-04-28 08:01:55
|
|
|
|
* @Description:
|
|
|
|
*
|
|
|
|
* 版权信息 : 2023 by ${再登软件}, All Rights Reserved.
|
|
|
|
-->
|
|
|
|
<template>
|
2023-06-27 09:00:43 +00:00
|
|
|
<div class="container">
|
|
|
|
<h2 class="title">
|
|
|
|
<DecorationFadeOut>
|
|
|
|
{{ t('messages.设备状态总览') }}
|
|
|
|
</DecorationFadeOut>
|
|
|
|
</h2>
|
|
|
|
<div class="ring" ref="ringRef"></div>
|
|
|
|
</div>
|
2023-06-12 09:06:00 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang='ts'>
|
2023-06-15 07:07:33 +00:00
|
|
|
import { ref, onMounted, onUnmounted, getCurrentInstance, watch, onUpdated } from 'vue'
|
2023-06-12 09:06:00 +00:00
|
|
|
const { proxy } = getCurrentInstance() as any;
|
|
|
|
import { useI18n } from 'vue-i18n'
|
2023-06-27 09:00:43 +00:00
|
|
|
import DecorationFadeOut from "@/components/decoration/DecorationFadeOut.vue";
|
2023-06-15 07:07:33 +00:00
|
|
|
let { t } = useI18n();
|
2023-06-12 09:06:00 +00:00
|
|
|
let ringRef = ref();
|
|
|
|
let ringChart = null;
|
|
|
|
const prop = defineProps({
|
2023-06-15 06:57:40 +00:00
|
|
|
data: [],
|
|
|
|
total: Number
|
2023-06-12 09:06:00 +00:00
|
|
|
})
|
|
|
|
const init = () => {
|
|
|
|
ringChart = proxy.$echarts.init(ringRef.value, 'dark')
|
|
|
|
let option = {
|
|
|
|
tooltip: {
|
|
|
|
trigger: "item",
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
type: "scroll",
|
2023-06-27 09:00:43 +00:00
|
|
|
top: "5%",
|
2023-06-12 09:06:00 +00:00
|
|
|
left: "center",
|
2023-06-15 06:57:40 +00:00
|
|
|
textStyle: {
|
|
|
|
color: "#fff",
|
|
|
|
fontSize: 16,
|
|
|
|
},
|
2023-06-12 09:06:00 +00:00
|
|
|
},
|
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "",
|
|
|
|
type: "pie",
|
2023-06-15 07:07:33 +00:00
|
|
|
radius: ["40%", "70%"],
|
2023-06-12 09:06:00 +00:00
|
|
|
center: ["50%", "45%"],
|
|
|
|
avoidLabelOverlap: false,
|
|
|
|
itemStyle: {
|
2023-06-15 07:07:33 +00:00
|
|
|
borderRadius: 10,
|
2023-06-12 09:06:00 +00:00
|
|
|
// borderColor: '#fff',
|
|
|
|
borderWidth: 2,
|
2023-06-15 07:07:33 +00:00
|
|
|
|
2023-06-12 09:06:00 +00:00
|
|
|
},
|
|
|
|
label: {
|
|
|
|
show: true,
|
2023-06-15 06:57:40 +00:00
|
|
|
formatter(params) {
|
|
|
|
return `${params.name} \n${(params.value / prop.total * 100).toFixed(2)}%`
|
|
|
|
},
|
2023-06-15 07:07:33 +00:00
|
|
|
fontSize: 20
|
2023-06-12 09:06:00 +00:00
|
|
|
},
|
|
|
|
labelLine: {
|
|
|
|
show: true,
|
|
|
|
},
|
2023-06-27 09:00:43 +00:00
|
|
|
top: '10%',
|
2023-06-12 09:06:00 +00:00
|
|
|
data: prop.data,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
ringChart.setOption(option)
|
|
|
|
}
|
|
|
|
|
|
|
|
onUpdated(() => {
|
|
|
|
ringChart.setOption({
|
|
|
|
series: [
|
|
|
|
{
|
|
|
|
data: prop.data
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
onMounted(() => {
|
|
|
|
init()
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2023-06-27 09:00:43 +00:00
|
|
|
.container {
|
2023-06-12 09:06:00 +00:00
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2023-06-27 09:00:43 +00:00
|
|
|
|
|
|
|
.title {
|
|
|
|
color: #fff;
|
|
|
|
font-size: 20px;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ring {
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100% - 50px);
|
|
|
|
}
|
2023-06-12 09:06:00 +00:00
|
|
|
</style>
|