https://echarts.apache.org/examples/zh/editor.html?c=bar-y-category-stack
image.png

  1. option = {
  2. tooltip: {
  3. trigger: 'axis',
  4. axisPointer: {
  5. // Use axis to trigger tooltip
  6. type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
  7. }
  8. },
  9. legend: {},
  10. grid: {
  11. left: '3%',
  12. right: '4%',
  13. bottom: '3%',
  14. containLabel: true
  15. },
  16. yAxis: {
  17. type: 'value'
  18. },
  19. xAxis: {
  20. type: 'category',
  21. data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  22. },
  23. series: [
  24. {
  25. name: 'Direct',
  26. type: 'bar',
  27. stack: 'total',
  28. label: {
  29. show: true
  30. },
  31. emphasis: {
  32. focus: 'series'
  33. },
  34. data: [320, 302, 301, 334, 390, 330, 320]
  35. },
  36. {
  37. name: 'Mail Ad',
  38. type: 'bar',
  39. stack: 'total',
  40. label: {
  41. show: true
  42. },
  43. emphasis: {
  44. focus: 'series'
  45. },
  46. data: [120, 132, 101, 134, 90, 230, 210]
  47. },
  48. {
  49. name: 'Affiliate Ad',
  50. type: 'bar',
  51. stack: 'total',
  52. label: {
  53. show: true
  54. },
  55. emphasis: {
  56. focus: 'series'
  57. },
  58. data: [220, 182, 191, 234, 290, 330, 310]
  59. },
  60. {
  61. name: 'Video Ad',
  62. type: 'bar',
  63. stack: 'total',
  64. label: {
  65. show: true
  66. },
  67. emphasis: {
  68. focus: 'series'
  69. },
  70. data: [150, 212, 201, 154, 190, 330, 410]
  71. },
  72. {
  73. name: 'Search Engine',
  74. type: 'bar',
  75. stack: 'total',
  76. label: {
  77. show: true
  78. },
  79. emphasis: {
  80. focus: 'series'
  81. },
  82. data: [820, 832, 901, 934, 1290, 1330, 1320]
  83. }
  84. ]
  85. };

label显示文字

label
image.png