Can echarts be configured as the following bar chart?

clipboard.png

4legend

clipboard.png

the data format is as follows

NSC: {
    plan: 10, // 
    construction: 25, // 
    siteSelection: 20, // 
    opening: 18 // 
 }

the series configuration is supposed to look like this, but the color of this bar chart is all the same. And it can"t be made into four legend

.
series: [
    {
        type:"bar",
        barWidth: "60%",
        data:[10, 25, 20, 18]
    }
]

I forcibly changed it to the following, which is exactly the same. the problem is that the following X-axis text is crooked because there are four in each place. Ask if there is any other way to achieve it.

series: [
    {
        name: ""
        type: "bar",
        barWidth: "60%"
        data: [10, 0, 0, 0]
    },
    {
        name: ""
        type: "bar",
        barWidth: "60%"
        data: [0, 25, 0, 0]
    },
    ...
]
Mar.04,2022

this?
http://www.cnblogs.com/kang54.


single bar No legend , multiple bar also take up space
is much simpler than solving legend problems
emphasis is on barGap attribute
http://www.echartsjs.com/opti.

.
 series : [
        {
            name:'',
            type:'bar',
            barGap:'-100%',
            data:[10, 0, 0, 0],
            itemStyle: {
                normal: {
                    color:'red'
                }
            },
        },
         {
            name:'',
            type:'bar',
            data:[0, 20, 0, 0],
            itemStyle: {
                normal: {
                    color:'blue'
                }
            },
        },
         {
            name:'',
            type:'bar',
            data:[0, 0, 30, 0],
            itemStyle: {
                normal: {
                    color:'yellow'
                }
            },
        },
        {
            name:'',
            type:'bar',
            data:[0, 0, 0, 40],
            itemStyle: {
                normal: {
                    color:'green'
                }
            },
        }
    ]

this type is really suitable for pie chart
, but if you insist on using a bar chart, you can change it to a stacked bar chart and add a stack: 'xxx'
https://codepen.io/caocong/pe.

in order not to be crooked.
Menu