echars柱状图堆叠加总量.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. app.title = '堆叠条形图';
  2. option = {
  3. tooltip : {
  4. trigger: 'axis',
  5. axisPointer : { // 坐标轴指示器,坐标轴触发有效
  6. type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  7. },
  8. formatter: function (params) {
  9. var str = "";
  10. var sum=0;
  11. for (var i=0;i<params.length;i++){
  12. sum+=params[i].value
  13. str += params[i].seriesName+ params[i].value+"</br>";
  14. }
  15. return "总量" + sum + "</br>" + str;
  16. }
  17. },
  18. legend: {
  19. data: ['直接访问', '邮件营销','联盟广告','视频广告','搜索引擎']
  20. },
  21. grid: {
  22. left: '3%',
  23. right: '4%',
  24. bottom: '3%',
  25. containLabel: true
  26. },
  27. yAxis: {
  28. type: 'value'
  29. },
  30. xAxis: {
  31. type: 'category',
  32. data: ['周一','周二','周三','周四','周五','周六','周日']
  33. },
  34. series: [
  35. {
  36. name: '直接访问',
  37. type: 'bar',
  38. stack: '总量',
  39. label: {
  40. normal: {
  41. show: true,
  42. position: 'insideRight'
  43. }
  44. },
  45. data: [320, 302, 301, 334, 390, 330, 320]
  46. },
  47. {
  48. name: '邮件营销',
  49. type: 'bar',
  50. stack: '总量',
  51. label: {
  52. normal: {
  53. show: true,
  54. position: 'insideRight'
  55. }
  56. },
  57. data: [120, 132, 101, 134, 90, 230, 210]
  58. },
  59. {
  60. name: '联盟广告',
  61. type: 'bar',
  62. stack: '总量',
  63. label: {
  64. normal: {
  65. show: true,
  66. position: 'insideRight'
  67. }
  68. },
  69. data: [220, 182, 191, 234, 290, 330, 310]
  70. },
  71. {
  72. name: '视频广告',
  73. type: 'bar',
  74. stack: '总量',
  75. label: {
  76. normal: {
  77. show: true,
  78. position: 'insideRight'
  79. }
  80. },
  81. data: [150, 212, 201, 154, 190, 330, 410]
  82. },
  83. {
  84. name: '搜索引擎',
  85. type: 'bar',
  86. stack: '总量',
  87. label: {
  88. normal: {
  89. show: true,
  90. position: 'insideRight'
  91. }
  92. },
  93. data: [820, 832, 901, 934, 1290, 1330, 1320]
  94. }
  95. ]
  96. };