Vue echarts 饼图 引导线加小圆点,文字分行展示

需求

在这里插入图片描述

重点代码

在这里插入图片描述
在这里插入图片描述

完整代码

  initChart() {
            // 创建 echarts 实例。
            var myChartOne = this.$echarts.init(this.$refs.Echart);
            myChartOne.setOption({
                tooltip: {
                    trigger: "item",
                },
                title: {
                    top: 'center',
                    text: [
                        '{name|' + this.chartTitle.name + '}',
                        '{value|' + this.chartTitle.value + '}',
                    ].join('\n'),

                    left: '50%',
                    top: '45%',
                    textAlign: 'center',
                    textStyle: {
                        rich: {
                            name: {
                                color: '#ffff',
                                fontSize: 12,
                                fontWeight: '700',
                                paddingBottom: 5,
                            },
                            value: {
                                color: '#ffff',
                                fontSize: 12,
                                fontWeight: '700',
                            },
                        },
                    },
                },
                color: this.colorArr,//自定义环形图颜色
                series: [
                    {
                        name: '',
                        type: 'pie',
                        radius: ['50%', '70%'],
                        center: ['50%', '50%'],
                        data: this.chartData,
                        label: {
                            //文字部分 显示内容为{b}:{c}可以换自己像显示的
                            //最外面的{a|}必要,不然位置有偏差,可以根据rich a微调
                            //{hr|}为圆点显示内容
                            // formatter: '{a|{c}} \n {hr|}',
                            lineHeight: 10,
                            formatter: [
                                '{a|{b}}', //name值
                                '{hr|}',//小圆点
                                '{p|{c}}',//value值
                                // 引导线下面文字
                            ].join('\n'), // 用\n来换行

                            //折线图文字颜色
                            color: "#fffdef",
                            rich: {
                                //圆点位置大小配置
                                hr: {
                                    //auto自定义
                                    backgroundColor: "auto",
                                    borderRadius: 5,
                                    width: 5,
                                    height: 5,
                                    padding: [0, -5],
                                },
                                a: {
                                    padding: [-10, 5, 0, 5]
                                },
                                p: {
                                    padding: [0, 5, 0, 5]
                                }
                            }
                        },
                        //折线图长度
                        labelLine: {
                            //第一段
                            length: 15,
                            //第二段
                            length2: 30
                        },

                    }
                ]
            });
        },

需求2

在这里插入图片描述

完整代码

initChart() {
            // 创建 echarts 实例。
            var myChartOne = this.$echarts.init(this.$refs.Echart);
            myChartOne.setOption({
                tooltip: {
                    trigger: "item",
                },
                title: {
                    top: 'center',
                    text: [
                        '{name|' + this.chartTitle.name + '}',
                        '{value|' + this.chartTitle.value + '}',
                    ].join('\n'),

                    left: '50%',
                    top: '45%',
                    textAlign: 'center',
                    textStyle: {
                        rich: {
                            name: {
                                color: '#ffff',
                                fontSize: 12,
                                fontWeight: '700',
                                paddingBottom: 5,
                            },
                            value: {
                                color: '#ffff',
                                fontSize: 12,
                                fontWeight: '700',
                            },
                        },
                    },
                },
                color: this.colorArr,//自定义环形图颜色
                series: [
                    {
                        name: '',
                        type: 'pie',
                        radius: ['50%', '70%'],
                        center: ['50%', '50%'],
                        data: this.chartData,
                        label: {
                            //文字部分 显示内容为{b}:{c}可以换自己像显示的
                            //最外面的{a|}必要,不然位置有偏差,可以根据rich a微调
                            //{hr|}为圆点显示内容
                            formatter: '{a|{b}:{c}}\n{hr|}',
                            //折线图文字颜色
                            color: "#fffdef",
                            rich: {
                                //圆点位置大小配置
                                hr: {
                                    //auto自定义
                                    backgroundColor: "auto",
                                    borderRadius: 3,
                                    width: 3,
                                    height: 3,
                                    padding: [3, 3, 0, -12]
                                },
                                a: {
                                    padding: [-10, 5, 0, 5]
                                },
                            }
                        },
                        //折线图长度
                        labelLine: {
                            //第一段
                            length: 15,
                            //第二段
                            length2: 25
                        },
                    }
                 ]
            });
        },

tips

圆点大小可以通过一下四个属性来修改
在这里插入图片描述
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值