使用title、graphic屬性在Echarts 餅圖中間添加文字


Echarts 的餅圖中間添加文字說明 ,主要使用graphic、title來完成配置,效果圖如下:

代碼示例:

 

// 指定圖表的配置項和數據
        var option = {
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)" },
            color:["#27D9C8","#D8D8D8"],
            title:{
                text:"80%",
                left:"center",
                top:"50%",
                textStyle:{
                    color:"#27D9C8",
                    fontSize:36,
                    align:"center" }
            },
            graphic:{ type:"text", //使用graphic來調節標題的樣式以及位置

                left:"center",
                top:"40%",
                style:{
                    text:"運動達標率",
                    textAlign:"center",
                    fill:"#333",
                    fontSize:20,
                    fontWeight:700
                }
            },
            series: [
                {
                    name: '運動情況', type: 'pie',
                    radius: ['65%', '70%'],
                    avoidLabelOverlap: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center' },
                       
                    },
                    
                    data: [
                        { value: 80, name: '已完成' },
                        { value: 20, name: '未完成' },
                       
                    ]
                }
            ]
        };

 


免責聲明!

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



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