關於餅圖環狀的標簽位置和引線設置


由兩個元素控制

option = {
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'left',
        data:['直接訪問','郵件營銷','聯盟廣告','視頻廣告','搜索引擎']
    },
    series: [
        {
            name:'訪問來源',
            type:'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show:false,
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data:[
                {value:335, name:'直接訪問'},
                {value:310, name:'郵件營銷'},
                {value:234, name:'聯盟廣告'},
                {value:135, name:'視頻廣告'},
                {value:1548, name:'搜索引擎'}
            ]
        }
    ]
};

以上代碼的運行結果如圖所示

 

 這里沒有引線和標簽,因為

label: {
                normal: {
                    show:false,//標簽隱藏
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: false//引線隱藏
                }
            },

label中設置了標簽和引線影藏,需要知道的是,如果你值設置labelLine可見,而沒有設置normal中的可見,即

label: {
                normal: {
                    show:false,
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: true
                }
            },

仍然不會出現標簽和引線

 

———————————————— 原文鏈接:https://blog.csdn.net/qq_31135027/article/details/79627402


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM