Echarts双Y轴柱状图

Bertha 。 2022-02-16 11:59 773阅读 0赞
  1. var option = {
  2. title: {
  3. text: '一周推送及完成率',
  4. x:'center',
  5. y:'top',
  6. align:'center',
  7. textStyle:{
  8. color:'#666666',
  9. fontWeight:'bolder',
  10. fontSize:28
  11. }
  12. },
  13. tooltip: {
  14. trigger: 'axis',
  15. formatter: function (params) { // 自定义toolTip提示框显示内容
  16. // alert(JSON.stringify(params));
  17. var res=''
  18. for(var i=0;i<params.length;i++){
  19. if(i===0){
  20. res+='<p>'+params[i].seriesName+':'+params[i].data+'</p>'
  21. }
  22. if(i===1){
  23. res+='<p>'+params[i].seriesName+':'+params[i].data+'%</p>'
  24. }
  25. }
  26. return res;
  27. },
  28. axisPointer: {
  29. // type: 'cross', 鼠标移动上去显示 虚刻度线
  30. crossStyle: {
  31. color: '#999'
  32. }
  33. },
  34. },
  35. toolbox: {
  36. show : false,
  37. top:10,
  38. right:10,
  39. feature : {
  40. mark : {show: false},
  41. magicType : {show: false, type: ['line', 'bar']},
  42. restore : {show: false},
  43. saveAsImage : {show: false}
  44. }
  45. },
  46. grid:{ //调整统计图上下左右边距
  47. top:80,
  48. right:70,
  49. bottom:50,
  50. left:75
  51. },
  52. legend: {
  53. top:45, // 统计图两个方块到Title的距离
  54. left:'center',
  55. data:['推送班级数','平均完成率']
  56. },
  57. calculable : true,
  58. xAxis : [
  59. {
  60. type : 'category',
  61. data : ['周一','周二','周三','周四','周五'],
  62. axisPointer: {
  63. type: 'shadow'
  64. },
  65. axisLabel: {
  66. show: true,
  67. textStyle: {
  68. color: '#666666',
  69. fontSize:22
  70. }
  71. },
  72. axisLine:{ // X轴线的颜色
  73. lineStyle:{
  74. color:'#D5D5D5',
  75. width:2
  76. }
  77. }
  78. }
  79. ],
  80. yAxis : [
  81. {
  82. splitLine: { //控制刻度横线的显示
  83. show: false
  84. },
  85. type: 'value',
  86. // max: 20,
  87. min: 0,
  88. interval:5,
  89. minInterval:5,
  90. // name:"推\n送\n班\n级\n数",
  91. nameLocation:"center",
  92. nameGap:35,
  93. nameRotate:0,
  94. nameTextStyle:{
  95. fontSize: 16,
  96. },
  97. axisLabel: {
  98. formatter: '{value} 个',
  99. show: true,
  100. textStyle: {
  101. color: '#666666',
  102. fontSize: 20
  103. }
  104. },
  105. axisLine:{ // Y轴线的颜色、和轴线的宽度
  106. lineStyle:{
  107. color:'#D5D5D5',
  108. width:2
  109. }
  110. }
  111. },
  112. {
  113. splitLine: {
  114. show: false
  115. },
  116. type: 'value',
  117. max: 100,
  118. min: 0,
  119. interval:20,
  120. // name:"平\n均\n完\n成\n率",
  121. nameLocation:"center",
  122. nameGap:50,
  123. nameRotate:0,
  124. nameTextStyle:{
  125. fontSize: 16,
  126. },
  127. axisLabel: {
  128. formatter: '{value}%',
  129. show: true,
  130. textStyle: {
  131. color: '#666666',
  132. fontSize: 20
  133. }
  134. },
  135. axisLine:{
  136. lineStyle:{
  137. color:'#D5D5D5',
  138. width:2
  139. }
  140. }
  141. }
  142. ],
  143. series : [
  144. {
  145. name:'推送班级数',
  146. type:'bar',
  147. yAxisIndex: 0,
  148. data:[20,26,30,25,55],
  149. itemStyle:{ //双Y轴A柱的柱体颜色
  150. normal:{
  151. color:'#77caff'
  152. }
  153. }
  154. },
  155. {
  156. name:'平均完成率',
  157. type:'bar',
  158. yAxisIndex: 1,
  159. data:[5,8,13,16,30],
  160. itemStyle:{ //双Y轴B柱的柱体颜色
  161. normal:{
  162. color:'#FFE482'
  163. }
  164. }
  165. }
  166. ]
  167. };

效果图:

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dueF81MjA1NQ_size_16_color_FFFFFF_t_70

发表评论

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

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

相关阅读