左右双柱图

描述:当前是关于Echarts图表中的 柱状图 示例。
 
            var xData = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
var lineData = [100, 100, 100, 100, 100, 100, 100]
var lastYearData = [3, 20, 42, 34, 35, 45, 33, 42, 34, 25, 35, 33];
var thisYearData = [11, 38, 23, 39, 46, 36, 29, 23, 39, 16, 36, 29];
var timeLineData = [1];
let legend = ['进库数', '出库数'];
var background = "#0e2147"; //背景 
let textColor = "#fff";
let lineColor = "rgba(255,255,255,0.2)";
let colors = [{
    borderColor: "rgba(220, 32, 85, 0.8)",
    start: "rgba(220, 32, 85, 0.8)",
    end: "rgba(220, 32, 86, 0.1)"
},
{
    borderColor: "rgba(91, 236, 204, 0.8)",
    start: "rgba(91, 236, 204, 0.1)",
    end: "rgba(91, 236, 204, 0.8)"
},
];
let borderData = [];
let scale = 2;
borderData = xData.map(item => {
    return scale;
});


var option = {
    baseOption: {
        timeline: {
            show: false,
            top: 0,
            data: []
        },
        tooltip: {
            trigger: 'axis',
            // type:'shadow',
            axisPointer: {
                type: 'shadow',
            },
            backgroundColor: 'rgba(17,95,182,0.5)',
            textStyle: {
                color: "#fff"
            },
            formatter: '{a}<br/>{b} :\n\n{c} 吨'
        },
        legend: {
            top: '5%',
            right: 'center',
            itemWidth: 20,
            itemHeight: 5,
            itemGap: 30,
            icon: 'horizontal',
            textStyle: {
                color: '#ffffff',
                fontSize: 14,
            },
            data: legend
        },
        grid: [
            // 左边
            {
                show: false,
                left: '2%',
                top: '15%',
                bottom: '21%',
                containLabel: true,
                width: '37%'
            },
            // 中间
            {
                show: false,
                left: '52%',
                top: '15%',
                bottom: '23%',
                width: '0%'
            },
            // 右边
            {
                show: false,
                right: '2%',
                top: '15%',
                bottom: '21%',
                containLabel: true,
                width: '37%'
            }],
        xAxis: [{
            type: 'value',
            inverse: true,
            axisLine: {
                show: true,
                lineStyle: {
                    color: 'rgba(45, 67, 119, 0.8)'
                }
            },
            axisTick: {
                show: false
            },
            position: 'bottom',
            axisLabel: {
                show: true,
                color: textColor
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#2D4377',
                    type: 'dashed',
                }
            },
        }, {
            gridIndex: 1,
            show: false
        }, {
            gridIndex: 2,
            axisLine: {
                show: true,
                lineStyle: {
                    color: 'rgba(45, 67, 119, 0.8)'
                }
            },
            axisTick: {
                show: false
            },
            position: 'bottom',
            axisLabel: {
                show: true,
                color: textColor
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#2D4377',
                    type: 'dashed',
                }
            },
        }],
        yAxis: [{
            type: 'category',
            inverse: true,
            position: 'right',
            axisLine: {
                show: true,
                lineStyle: {
                    color: lineColor
                }
            },

            axisTick: {
                show: false
            },
            axisLabel: {
                show: false
            },
            data: xData
        }, {
            gridIndex: 1,
            type: 'category',
            inverse: true,
            position: 'left',
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                show: true,
                // padding:[10,0,0,0],
                textStyle: {
                    color: '#ffffff',
                    fontSize: 13
                },
                align: "center"

            },
            data: xData.map(function (value) {
                return {
                    value: value,
                    textStyle: {
                        align: 'center'
                    }
                }
            })
        }, {
            gridIndex: 2,
            type: 'category',
            inverse: true,
            position: 'left',
            axisLine: {
                show: true,
                lineStyle: {
                    color: lineColor
                }
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                show: false

            },
            data: xData
        }],
        series: []

    },
    options: []
}

// option.baseOption.timeline.data.push(timeLineData[0])
option.options.push({
    backgroundColor: '#081736',
    series: [{
        name: "进库数",
        type: "bar",
        barWidth: 10,
        stack: "1",
        itemStyle: {
            normal: {
                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                    offset: 0,
                    color: colors[0].start
                },
                {
                    offset: 1,
                    color: colors[0].end
                }
                ]),
            }
        },
        label: {
            normal: {
                show: false,
            }
        },
        data: lastYearData,
        animationEasing: "elasticOut"
    },
    {
        name: "出库数",
        type: "bar",
        stack: "2",
        barWidth: 10,
        xAxisIndex: 2,
        yAxisIndex: 2,
        itemStyle: {
            normal: {
                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                    offset: 0,
                    color: colors[1].start
                },
                {
                    offset: 1,
                    color: colors[1].end
                }
                ]),
            }
        },
        label: {
            normal: {
                show: false,
            }
        },
        data: thisYearData,
        animationEasing: "elasticOut"
    },
    ]
});
if (option && typeof option === "object") {
    myChart.setOption(option, true);
    var index8 = 0; //播放所在下标
    var mTime = setInterval(function () {
        myChart.dispatchAction({
            type: 'showTip',
            seriesIndex: 0,
            dataIndex: index8
        });
        index8++;
        if (index8 >= 12) {
            //console.log('data4', fxdata.length)
            index8 = 0;
            //console.log(fxdata)
        }
    }, 3000);
}