echarts饼图不同样式

仅做个人收藏记录。

1. 双层饼图

let htjc_option4_data = [
            { value: 78, name: '网上申请合同数', textStyle: { color: '#28b1ff' } },
            { value: 22, name: '线下申请合同数', textStyle: { color: '#1ae562' } },
        ];
option={
            tooltip: {
                trigger: 'item'
            },
            color: ['#28b1ff', '#1ae562'],
            legend: {
                data: [{
                    name: '网上申请合同数',
                    textStyle: {
                        color: '#28b1ff'
                    }
                }, {
                    name: '线下申请合同数',
                    textStyle: {
                        color: '#1ae562'
                    }
                }],
                orient: 'vertical',
                right: '5%',
                top: '5%',
                itemGap: 25,
                itemWidth: 14,
                itemHeight: 14,
                textStyle: {
                    color: 'auto',
                    fontSize: 14,
                    padding: [0, 0, 0, 5],
                    rich: {
                        name: {
                            fontSize: 14,
                            color: '#fff'
                        },
                        b: {
                            fontSize: 14,
                            color: 'auto',
                            fontWeight: 'bold'
                        },
                        v: {
                            fontSize: 14,
                            color: 'auto',
                            fontWeight: 'bold'
                        }
                    }
                },
                icon: 'rect',
                formatter: name => {
                    var data = htjc_option4.series[0].data;
                    var total = 0;
                    var tarValue;
                    for (var i = 0; i < data.length; i++) {
                        total += data[i].value;
                        if (data[i].name == name) {
                            tarValue = data[i].value;
                        }
                    }
                    var v = tarValue;
                    var b = Math.round((tarValue / total) * 100);
                    return '{name|' + name + '}' + '   ' + "{b| " + b + "%}" + ' ' + "{v| " + v + "万平方米}";
                }
            },
            series: [
                {
                    type: 'pie',
                    radius: ['35%', '55%'],
                    center: ['35%', '62%'],
                    label: {
                        show: false,
                    },
                    labelLine: {
                        show: false
                    },
                    data: htjc_option4_data
                }, {
                    type: 'pie',
                    radius: ['55%', '65%'],
                    center: ['35%', '62%'],
                    hoverAnimation: false,
                    label: {
                        normal: {
                            show: false,
                        },
                        emphasis: {
                            show: false,
                        },
                    },
                    labelLine: {
                        normal: {
                            show: false,
                        },
                        emphasis: {
                            show: false,
                        },
                    },
                    animation: false,
                    tooltip: {
                        show: false,
                    },
                    data: [
                        {
                            value: 1,
                            itemStyle: {
                                color: "rgba(255,255,255,0.2)",
                            },
                        },
                    ],
                }
            ]
        }

2. 

var ecologicalOption = {
        tooltip: {
            show: false
        },
        color: ['#2a2ac7', '#3657c8', '#53b1f9'],
        legend: {
            left: 'center',
            top: 20,
            itemGap: 20,
            textStyle: {
                color: '#fff',
                fontSize: 12
            }
        },
        series: [
            {
                type: 'pie',
                radius: '55%',
                // top: '6%',
                data: [
                    { value: 1048, name: '供地盘活' },
                    { value: 735, name: '转让盘活' },
                    { value: 580, name: '增容改进' }
                ],
                label: {
                    normal: {
                        show: true,
                        formatter: '{b|{b}}\n{d|{d}%}',
                        rich: {
                            b: {
                                color: '#fff',
                                fontSize: 12,
                                align: 'center',
                                padding: [0, 0, 5, 0]
                            },
                            c: {
                                fontSize: 12,
                                color: '#10d0f5',
                                fontWeight: '700'
                            },
                            d: {
                                fontSize: 12,
                                color: '#baeaf3',
                                fontWeight: '700'
                            }
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: true,
                        length: 20,
                        length2: 50,
                        lineStyle: {
                            color: '#3874b5',
                            width: 2
                        }
                    }
                }
            }
        ]
    }

 

引用中提到了echarts饼图图例样式的修改。可以通过对legend对象进行修改来改变图例的样式。在legend中可以设置orient属性来确定图例的方向,可以设置x属性来确定图例的位置。可以使用data属性来设置图例的数据项,可以使用icon属性来设置图例的图标样式。可以使用formatter属性来自定义图例的文本格式,通过修改formatter函数中的代码,可以实现对图例文本的自定义样式。可以使用textStyle属性来设置图例文本的样式,可以使用rich属性来进一步设置富文本样式。根据需求可以根据以上属性来调整echarts饼图的图例样式。<span class="em">1</span><span class="em">2</span> #### 引用[.reference_title] - *1* [Axure8.0基于Echarts的动态图表元件库,实用版本](https://download.csdn.net/download/weixin_54626591/85812795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [Echarts 饼图 图例修改,legend样式修改](https://blog.csdn.net/qq_41954585/article/details/122585663)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值