123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <template>
- <div class="dz-risk">
- <div class="risk-container">
- <div class="risk-center"></div>
- <div ref="riskPie" class="risk-pie"></div>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { ref, nextTick, onMounted, watch } from 'vue';
- import * as echarts from 'echarts';
- let props = defineProps({
- echartData: {
- type: Array,
- default: () => {
- return [];
- },
- },
- });
- let riskPie = ref(null);
- let echartData = ref<any[]>([]);
- function getOption() {
- nextTick(() => {
- const colorList = [
- {
- type: 'radial',
- r: 1,
- colorStops: [
- {
- offset: 0,
- color: 'rgba(182, 242, 255,1)', // 0% 处的颜色
- },
- {
- offset: 1,
- color: 'rgba(95, 228, 255,1)', // 100% 处的颜色
- },
- ],
- },
- {
- type: 'radial',
- r: 1,
- colorStops: [
- {
- offset: 0,
- color: 'rgba(176, 255, 236,1)', // 0% 处的颜色
- },
- {
- offset: 1,
- color: 'rgba(86, 255, 171,1)', // 100% 处的颜色
- },
- ],
- },
- {
- type: 'radial',
- r: 1,
- colorStops: [
- {
- offset: 0,
- color: 'rgba(255, 253, 176,1)', // 0% 处的颜色
- },
- {
- offset: 1,
- color: 'rgba(255, 255, 86,1)', // 100% 处的颜色
- },
- ],
- },
- {
- type: 'radial',
- r: 1,
- colorStops: [
- {
- offset: 0,
- color: 'rgba(215, 179, 255,1)', // 0% 处的颜色
- },
- {
- offset: 1,
- color: 'rgba(134, 88, 255,1)', // 100% 处的颜色
- },
- ],
- },
- ];
- let myChart = echarts.init(riskPie.value);
- let option = {
- color: colorList,
- // tooltip: {
- // trigger: 'item'
- // },
- series: [
- {
- type: 'pie',
- center: ['50%', '50%'],
- radius: ['30%', '50%'],
- emphasis: {
- label: {
- show: true,
- },
- opacity: 1,
- color: function (params) {
- return colorList[params.dataIndex];
- },
- },
- itemStyle: {
- normal: {
- color: function (params) {
- return colorList[params.dataIndex];
- },
- },
- },
- label: {
- show: true,
- position: 'outside',
- textStyle: {
- color: '#fff',
- fontSize: 10,
- },
- formatter: '{b}:{c}',
- rich: {
- a: {
- padding: [-10, 5, -15, 5],
- },
- },
- },
- labelLine: {
- normal: {
- length: 10,
- length2: 5,
- lineStyle: {
- width: 1,
- },
- },
- },
- data: echartData.value,
- },
- ],
- };
- myChart.setOption(option);
- window.onresize = function () {
- myChart.resize();
- };
- });
- }
- watch(
- () => props.echartData,
- (newV, oldV) => {
- echartData.value = newV;
- getOption();
- },
- { immediate: true }
- );
- </script>
- <style lang="less" scoped>
- @import '/@/design/theme.less';
- .dz-risk {
- --image-model_risk-container: url('@/assets/images/home-warn/2.png');
- --image-model_risk-center: url('@/assets/images/home-warn/1.png');
- height: 100%;
- .risk-container {
- position: relative;
- height: 100%;
- width: 100%;
- height: 100%;
- background: var(--image-model_risk-container) no-repeat center;
- background-size: auto 100%;
- .risk-center {
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- width: 100%;
- height: 60px;
- background: var(--image-model_risk-center) no-repeat center;
- background-size: auto 100%;
- }
- .risk-pie {
- left: -48px;
- top: -17px;
- position: absolute;
- width: 276px;
- height: 205px;
- }
- }
- }
- </style>
|