ECharts3实例 定制图例、XY轴、叠加柱状图

淡淡的烟草味﹌ 2021-07-26 17:18 644阅读 0赞

前言

  1. 实现如下效果图

在这里插入图片描述

解决方法

  1. option = {
  2. tooltip: {
  3. trigger: 'axis',
  4. backgroundColor: "rgba(255,255,255)", //设置背景图片 rgba格式
  5. color: "black",
  6. borderColor: "gray", //设置边框颜色
  7. textStyle: {
  8. color: "red" //设置文字颜色
  9. },
  10. },
  11. legend: {
  12. data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎'],
  13. icon: "roundRect",
  14. itemWidth: 10, // 设置宽度
  15. itemHeight: 10, // 设置高度
  16. left: '50px' ,
  17. textStyle: {
  18. color: 'red'
  19. }
  20. },
  21. // grid: {
  22. // left: '3%',
  23. // right: '4%',
  24. // bottom: '3%',
  25. // containLabel: true
  26. // },
  27. yAxis: {
  28. type: 'value',
  29. axisLabel: {
  30. formatter: '{value} ml',
  31. color: '#fff'
  32. },
  33. axisLine:{
  34. lineStyle:{
  35. color:'#fff'
  36. }
  37. },
  38. splitLine:{
  39. lineStyle: {
  40. type: 'dashed',
  41. width: 2,
  42. color: 'red'
  43. }
  44.   }
  45. },
  46. xAxis: {
  47. type: 'category',
  48. data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  49. axisPointer: {
  50. type: 'shadow'
  51. },
  52. axisLabel: {
  53. color: 'red'
  54. },
  55. axisTick: { show: false },
  56. //设置轴线的属性
  57. axisLine:{
  58. lineStyle:{
  59. color:'#ddd'
  60. }
  61. }
  62. },
  63. series: [
  64. {
  65. name: '直接访问',
  66. type: 'bar',
  67. stack: '总量',
  68. label: {
  69. show: true
  70. },
  71. barMaxWidth: 40,
  72. itemStyle: {
  73. color: 'red'
  74. },
  75. data: [320, 302, 301, 334, 390, 330, 320]
  76. },
  77. {
  78. name: '邮件营销',
  79. type: 'bar',
  80. stack: '总量',
  81. label: {
  82. show: true
  83. },
  84. data: [120, 132, 101, 134, 90, 230, 210]
  85. },
  86. {
  87. name: '联盟广告',
  88. type: 'bar',
  89. stack: '总量',
  90. label: {
  91. show: true
  92. },
  93. data: [220, 182, 191, 234, 290, 330, 310]
  94. },
  95. {
  96. name: '视频广告',
  97. type: 'bar',
  98. stack: '总量',
  99. label: {
  100. show: true
  101. },
  102. data: [150, 212, 201, 154, 190, 330, 410]
  103. },
  104. {
  105. name: '搜索引擎',
  106. type: 'bar',
  107. stack: '总量',
  108. label: {
  109. show: true
  110. },
  111. data: [820, 832, 901, 934, 1290, 1330, 1320]
  112. }
  113. ]
  114. };

发表评论

表情:
评论列表 (有 0 条评论,644人围观)

还没有评论,来说两句吧...

相关阅读