关于echarts:echart-图例文字设置不同样式不同系列柱子重叠居中

7次阅读

共计 625 个字符,预计需要花费 2 分钟才能阅读完成。

option = {

    legend: {formatter:  (name)=>{let arr = '{a|'+name+'}'+'{b|'+name+'西方小道}'
            return arr
        },
        textStyle:{
            rich:{
                a:{
                    fontSize:16,
                    color:'red',
                      padding: [0, 0, 0, 20]
                },
                b:{
                    fontSize:14,
                    color:'blue',
                      padding: [0, 0, 0, 20]
                }
            }
        },
     
        data:[
           '预计',
           '理论',
        ],
      
    },
 
    xAxis: {
        show:true,
        type: 'value',
        max:200
    },
    yAxis: [
        {
            type: 'category',
            axisTick: 'none',
            axisLine: 'none',
            data: []},
        {
            show: false,
           type: 'category',
            axisTick: 'none',
            data: [],
            axisLine: 'none',
        },
        ],
    series: [
        {
            name:'理论',
            type: 'bar',
            barWidth:'50',
            yAxisIndex: 0,
           itemStyle: {color: '#ddd',},
            z:2,
            data: [180]
        },
        {
             name:'预计',
            barGap: '-100%', // Make series be overlap
            barWidth:'60',
            yAxisIndex: 1,
            z:1,
            itemStyle: {color: '#444',},
            type: 'bar',
            data: [200]
        },
    ]
};
正文完
 0