效果示例:
    bar-stack.png

    示例代码:

    1. import * as echarts from 'echarts';
    2. var chartDom = document.getElementById('main');
    3. var myChart = echarts.init(chartDom);
    4. var option;
    5. option = {
    6. xAxis: {
    7. data: ['a', 'b', 'c', 'd'],
    8. axisTick: {
    9. show: false
    10. }
    11. },
    12. yAxis: {
    13. splitLine: {
    14. show: false
    15. }
    16. },
    17. animationDurationUpdate: 1200,
    18. series: [
    19. {
    20. type: 'bar',
    21. itemStyle: {
    22. normal: {
    23. color: 'transparent',
    24. barBorderColor: 'tomato',
    25. barBorderWidth: 2,
    26. barBorderRadius: 3,
    27. borderType: 'dotted'
    28. }
    29. },
    30. silent: true,
    31. barWidth: 40,
    32. barGap: '-100%', // 柱子重叠
    33. data: [60, 60, 60, 60]
    34. },
    35. {
    36. type: 'bar',
    37. barWidth: 40,
    38. z: 10,
    39. data: [40, 60, 13, 25]
    40. }
    41. ]
    42. };
    43. option && myChart.setOption(option);