Echart 餅圖標籤label重寫formatter問題

1、在label重寫上,2.0與3.0 formatter用法稍有區別,數據層級結構變化

2.0

{
    name:'訪問來源',
    type:'pie',
    selectedMode: 'single',
    radius : [0, 70],
    
    // for funnel
    x: '20%',
    width: '40%',
    funnelAlign: 'right',
    max: 1548,
    
    itemStyle : {
        normal : {
            label : {
                position : 'inner',
                formatter:function(params){
                    return "重寫label"
                }
            },
            labelLine : {
                show : false
            }
        }
    },
    data:[
        {value:335, name:'直達'},
        {value:679, name:'營銷廣告'},
        {value:1548, name:'搜索引擎', selected:true}
    ]
},

3.0

{
    name:'訪問來源',
    type:'pie',
    radius: ['40%', '55%'],
    label: {
        normal: {
            formatter:function(parmas){
                return "重寫label"
            },
            backgroundColor: '#eee',
            borderColor: '#aaa',
            borderWidth: 1,
            borderRadius: 4,
            rich: {
                a: {
                    color: '#999',
                    lineHeight: 22,
                    align: 'center'
                },
                hr: {
                    borderColor: '#aaa',
                    width: '100%',
                    borderWidth: 0.5,
                    height: 0
                },
                b: {
                    fontSize: 16,
                    lineHeight: 33
                },
                per: {
                    color: '#eee',
                    backgroundColor: '#334455',
                    padding: [2, 4],
                    borderRadius: 2
                }
            }
        }
    },
    data:[
        {value:335, name:'直達'},
        {value:310, name:'郵件營銷'},
        {value:234, name:'聯盟廣告'},
        {value:135, name:'視頻廣告'},
        {value:1048, name:'百度'},
        {value:251, name:'谷歌'},
        {value:147, name:'必應'},
        {value:102, name:'其他'}
    ]
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章