【Vue3】 echarts雷达图 [文字标题过长显示不全]

1、代码

<template>
    <!-- 双预防运行结果 -->
    <div style="width: 1400px; height: 1000px; display: flex; padding: 0 10px">
        <v-chart :option="option" autoresize style="width: 85%;margin-right: 30px;" />
    </div>
</template>

<script lang="ts">
export default {
    name: 'DualPreventionOperation',
}
</script>
<script lang="ts" setup>
import { useDataStatus, dialogTypeEnum } from '@/stores/dialog/data-status'
import VChart from 'vue-echarts'

const dataStatus = useDataStatus()
onMounted(() => {

})
const obj = dataStatus.dialogMap.get(dialogTypeEnum.prevention_operation).condition?.row
//visualMap 填充色对比 最大值
const option = ref(
    {
        backgroundColor: 'rgb(30, 36, 50)',
        tooltip: {
            'show': true,
            'trigger': 'item',
        },

        radar: {
            // shape: 'circle',
            radius: '65%',
            name: {
                textStyle: {
                    color: '#fff',
                    //backgroundColor: '#999',
                    borderRadius: 3,
                    padding: [-10, -10],
                    fontSize: 20
                },
                formatter: function (value) {                    
                    let list = value.split("");
                    console.log(list);
                    let result = "";
                    for (let i = 1; i <= list.length; i++) {
                        if (!(i % 7) && list[i] != undefined) {
                            result += list[i - 1] + '\n';
                        } else {
                            result += list[i - 1];
                        }
                    }
                    return result;
                },
            },
            axisLine: {
                lineStyle: {
                    color: '#1968a0',
                    width: 1,
                    type: 'solid'
                },
            },

            splitArea: {
                areaStyle: {

                    color: ['rgba(40,203,228,0.3)', 'rgb(30, 36, 50,0.7)']
                }
            },
            splitLine: {
                lineStyle: {
                    color: ['#74e7f0', '#74e7f0', '#74e7f0', '#74e7f0'],
                    width: 1
                }
            },
            indicator: [{
                text: '风险分析完成率',
            }, {
                text: '隐患整改率',
            }, {
                text: '排查任务完成率',
            },
            ]
        },
        series: [{
            name: '双预防运行结果',
            type: 'radar',
            symbol: 'circle',
            symbolSize: 3,
            areaStyle: {
                normal: {
                    color: 'rgba(103,194,58,0.3)',
                    fontSize: 24
                },
            },
            itemStyle: {
                color: 'rgba(103,194,58,.7)',
                borderColor: 'rgba(103,194,58,.5)',
                borderWidth: 5,
            },

            data: [
                {
                    value: [obj.num9, obj.num10, obj.num11],
                    name: '双预防运行结果'
                }],

        }]
    }
)

</script>

<style lang="scss" scoped></style>

注意:

1)、文字显示不全

        解决:

           <1>、radius: '65%',   // 设置这个文字少的情况下可解决

           <2>、上诉代码formatter这个方法,可解决文字过长进行换行展示

2)、indicator中可以设置max值

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值