横柱状图

描述:当前是关于Echarts图表中的 柱状图 示例。
 
            var data = [50, 60, 70, 20, 30, 10, 20, 23, 43, 52, 51];
var className = ['100+', '91-100', '81-90', '71-80', '61-70', '51-60', '41-50', '31-40', '21-30', '11-20', '0-10'];
var defaultData = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100];
option = {
    grid: {
        left: '5%',
        right: '5%',
        bottom: 25,
        top: 20,
        containLabel: true,
    },
    legend: {
        show: true,
        itemWidth: 16,
        itemHeight: 16,
        right: "5%",
        top: "0%",
        textStyle: {
            color: "#fff",
            fontSize: '16',
        },
        data: ["人数"]
    },
    backgroundColor: '#002D54',
    xAxis: {
        type: 'value',
        splitLine: {
            show: false
        },
        axisTick: {
            show: false
        },
        axisLabel: { //  改变x轴字体颜色和大小
            show: false
        }
    },
    yAxis: [
        {
            type: 'category',
            inverse: true,
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#80CFF0',
                    fontSize: '16',
                },
            },
            splitLine: {
                show: false,
            },
            axisTick: {
                show: false,
            },
            axisLine: {
                show: false,
            },
            data: className,
        },
        {
            type: 'category',
            inverse: true,
            axisTick: 'none',
            axisLine: 'none',
            show: true,
            axisLabel: {
                textStyle: {
                    color: '#CFEFFF',
                    fontSize: '16',
                },

                formatter: function (value) {
                    return '均' + value + '岁';
                },
            },
            data: data,
        },
    ],
    series: [
        {
            name: '人数',
            type: 'bar',
            zlevel: 1,
            itemStyle: {
                normal: {
                    barBorderRadius: 0,
                    color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                        {
                            offset: 0,
                            color: 'rgba(0, 151, 251, 1)',
                        },
                        {
                            offset: 1,
                            color: 'rgba(48, 236, 166, 1)',
                        },
                    ]),
                },
            },
            barWidth: 20,
            data: data,
        },
        {
            name: '背景',
            type: 'bar',
            barWidth: 20,
            barGap: '-100%',
            data: defaultData,
            itemStyle: {
                normal: {
                    color: 'rgba(0, 151, 251, 0.2)',
                    barBorderRadius: 0,
                },
            },
        },
    ],
};