left3_d.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //检查督导
  2. var myChart8 = echarts.init(document.getElementById('left3_d'), 'vintage');
  3. var colorList1 = ['#f0422a', '#ffa531', '#00a041', '#41cafe'];
  4. var datas = [{
  5. value: 96,
  6. name: '一队',
  7. },
  8. {
  9. value: 94,
  10. name: '二队',
  11. },
  12. {
  13. value: 89,
  14. name: '三队',
  15. },
  16. {
  17. value: 85,
  18. name: '监察部',
  19. },
  20. {
  21. value: 75,
  22. name: '三连',
  23. },
  24. {
  25. value: 69,
  26. name: '四队',
  27. },
  28. {
  29. value: 65,
  30. name: '一连',
  31. },
  32. {
  33. value: 65,
  34. name: '后勤',
  35. },
  36. {
  37. value: 61,
  38. name: '一大队',
  39. },
  40. {
  41. value: 60,
  42. name: '保障部',
  43. },
  44. ];
  45. var end = 3;
  46. var start = -1;
  47. function autoChangea() {
  48. if (end == datas.length-1 ) {
  49. start=0;
  50. end=3;
  51. }
  52. else {
  53. start+=1;
  54. end+=1;
  55. }
  56. let maxArr = new Array(datas.length).fill(100);
  57. var option = {
  58. dataZoom: [
  59. {
  60. type: 'slider',
  61. width:5,
  62. show: true,
  63. yAxisIndex: [0],
  64. left: '93%',
  65. handleColor:'#68789c',
  66. startValue: start, //数据窗口范围的起始百分比
  67. endValue:end,
  68. },
  69. {
  70. type: 'inside',
  71. yAxisIndex: [0],
  72. startValue: start, //数据窗口范围的起始百分比
  73. endValue:end,
  74. }
  75. ],
  76. tooltip: {
  77. trigger: 'axis',
  78. axisPointer: {
  79. type: 'shadow',
  80. },
  81. },
  82. legend: {
  83. show: false,
  84. },
  85. grid: {
  86. top: 20,
  87. bottom: 0,
  88. left: 0,
  89. right: 40,
  90. containLabel: true,
  91. },
  92. xAxis: {
  93. show: false,
  94. type: 'value',
  95. },
  96. yAxis: [{
  97. type: 'category',
  98. inverse: true,
  99. axisLine: {
  100. show: false,
  101. },
  102. axisTick: {
  103. show: false,
  104. },
  105. axisPointer: {
  106. label: {
  107. show: true,
  108. margin: 30,
  109. },
  110. },
  111. data: datas.map((item) => item.name),
  112. axisLabel: {
  113. margin: 40,
  114. fontSize: 12,
  115. align: 'left',
  116. color: '#fff',
  117. rich: {
  118. a1: {
  119. color: '#fff',
  120. backgroundColor: colorList1[0],
  121. width: 20,
  122. height: 20,
  123. align: 'center',
  124. borderRadius: 2,
  125. },
  126. a2: {
  127. color: '#fff',
  128. backgroundColor: colorList1[1],
  129. width: 20,
  130. height: 20,
  131. align: 'center',
  132. borderRadius: 2,
  133. },
  134. a3: {
  135. color: '#fff',
  136. backgroundColor: colorList1[2],
  137. width: 20,
  138. height: 20,
  139. align: 'center',
  140. borderRadius: 2,
  141. },
  142. b: {
  143. color: '#fff',
  144. backgroundColor: colorList1[3],
  145. width: 20,
  146. height: 20,
  147. align: 'center',
  148. borderRadius: 2,
  149. },
  150. },
  151. formatter: function (params) {
  152. var index = datas.map((item) => item.name).indexOf(params);
  153. index = index + 1;
  154. if (index - 1 < 3) {
  155. return ['{a' + index + '|' + index + '}' + ' '].join('\n');
  156. } else {
  157. return ['{b|' + index + '}' + ' '].join('\n');
  158. }
  159. },
  160. },
  161. }, ],
  162. series: [{
  163. z: 2,
  164. name: '加分',
  165. type: 'bar',
  166. barWidth: 15,
  167. zlevel: 1,
  168. data: datas.map((item, i) => {
  169. itemStyle = {
  170. color: i > 3 ? colorList1[3] : colorList1[i],
  171. barBorderRadius: 30,
  172. };
  173. return {
  174. value: item.value,
  175. itemStyle: itemStyle,
  176. };
  177. }),
  178. label: {
  179. show: true,
  180. position: 'insideTopRight',
  181. padding: [-24, 24, -24, 0],
  182. color: '#fff',
  183. formatter: '{c}分',
  184. fontSize: 14,
  185. offset: [10, 0],
  186. },
  187. },
  188. {
  189. z: 2,
  190. name: '扣分',
  191. type: 'bar',
  192. barWidth: 15,
  193. zlevel: 1,
  194. data: datas.map((item, i) => {
  195. itemStyle = {
  196. color: i > 3 ? colorList1[3] : colorList1[i],
  197. barBorderRadius: 30,
  198. };
  199. return {
  200. value: 100 - item.value,
  201. itemStyle: itemStyle,
  202. };
  203. }),
  204. label: {
  205. show: true,
  206. position: 'insideTopLeft',
  207. padding: [-24, 24, -24, 0],
  208. color: '#fff',
  209. formatter: '{b}',
  210. fontSize: 14,
  211. offset: [10, 0],
  212. },
  213. },
  214. {
  215. name: '满分',
  216. type: 'bar',
  217. barWidth: 15,
  218. barGap: '-100%',
  219. itemStyle: {
  220. normal: {
  221. color: '#0c1231',
  222. barBorderRadius: 30,
  223. },
  224. },
  225. data: maxArr,
  226. },
  227. ],
  228. };
  229. myChart8.setOption(option);
  230. }
  231. autoChangea(); //初始化实例后,首次设置数据
  232. setInterval(function () {
  233. // 每次向后滚动一个,最后一个从头开始。
  234. autoChangea();
  235. }, 5000);