cqzrqs.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div>
  3. <jt-echarts style="width: 320rem;height: 260rem;margin:10rem 10rem 10rem 20rem;"
  4. :chartData="option"></jt-echarts>
  5. </div>
  6. </template>
  7. <script>
  8. // import * as echarts from "echarts";
  9. export default {
  10. data() {
  11. return {
  12. // category: "", //横坐标
  13. // yData: [1000, 1500, 1300, 1700, 1600, 1200],
  14. // y2Data: [1200, 1800, 1400, 1350, 1100, 1500],
  15. option: {}
  16. }
  17. },
  18. created() {},
  19. mounted() {
  20. this.typeCharts0()
  21. // let _this = this
  22. // var t1=setTimeout(function() {
  23. // _this.option.series = [{
  24. // data: _this.category
  25. // },
  26. // {
  27. // data: _this.dottedBase
  28. // }
  29. // ]
  30. // }, 1000);
  31. },
  32. methods: {
  33. typeCharts0() {
  34. var getName =['小花','小明','小红','吓不不','刃甲','加加','鸿基','新能源','家喻户晓','老师'];
  35. var getValue =[219,241,174,44,435,617,114,82,77,50];
  36. var max = Math.max.apply(null, getValue);
  37. var getMax=[];
  38. for(var i=0;i<getName.length;i++){
  39. getMax.push(max)
  40. }
  41. console.log(getMax) ;
  42. // typeCharts0() {
  43. // this.option = this.getOption();
  44. // // var chartDom = document.getElementById('echarts');
  45. // // var myChart = echarts.init(chartDom);
  46. // // myChart.setOption(option, true);
  47. // },
  48. this.option = {
  49. // backgroundColor: "#003366",
  50. grid: {
  51. left: '4%',
  52. right: '2%',
  53. bottom: '2%',
  54. top: '2%',
  55. containLabel: true
  56. },
  57. tooltip: {
  58. trigger: 'axis',
  59. axisPointer: {
  60. type: 'none'
  61. },
  62. formatter: function(params) {
  63. return params[0].name + ' : ' + params[0].value
  64. }
  65. },
  66. xAxis: {
  67. show: false,
  68. type: 'value'
  69. },
  70. yAxis: [{
  71. type: 'category',
  72. inverse: true,
  73. offset: 100,
  74. axisLabel: {
  75. show: true,
  76. align: 'left',
  77. textStyle: {
  78. color: '#66cc00',
  79. },
  80. formatter: function(value, index) {
  81. var num = ''
  82. var str = ''
  83. var no = 'NO.';
  84. num = (index + 1);
  85. if (index === 0) {
  86. str = '{no1|' + no + '} {num1|' + num + '} {title1|' + value + '}'
  87. } else if (index === 1) {
  88. str = '{no2|' + no + '} {num2|' + num + '} {title2|' + value + '}'
  89. } else if (index === 2) {
  90. str = '{no3|' + no + '} {num3|' + num + '} {title3|' + value + '}'
  91. } else {
  92. str = '{no|' + no + '} {num|' + num + '} {title|' + value + '}'
  93. }
  94. return str;
  95. },
  96. rich: {
  97. no: {
  98. color: '#ffcccc',
  99. fontSize: 14,
  100. },
  101. no1: {
  102. color: '#ff4d4d',
  103. fontSize: 14,
  104. },
  105. no2: {
  106. color: '#4dd2ff',
  107. fontSize: 14,
  108. },
  109. no3: {
  110. color: '#ffff00',
  111. fontSize: 14,
  112. },
  113. num: {
  114. color: '#fff',
  115. backgroundColor: '#ffcccc',
  116. width: 20,
  117. height: 20,
  118. fontSize: 14,
  119. align: 'center',
  120. borderRadius: 100
  121. },
  122. num1: {
  123. color: '#fff',
  124. backgroundColor: '#ff4d4d',
  125. width: 20,
  126. height: 20,
  127. fontSize: 14,
  128. align: 'center',
  129. borderRadius: 100
  130. },
  131. num2: {
  132. color: '#fff',
  133. backgroundColor: '#4dd2ff',
  134. width: 20,
  135. height: 20,
  136. fontSize: 14,
  137. align: 'center',
  138. borderRadius: 100
  139. },
  140. num3: {
  141. color: '#fff',
  142. backgroundColor: '#ffff00',
  143. width: 20,
  144. height: 20,
  145. fontSize: 14,
  146. align: 'center',
  147. borderRadius: 100
  148. },
  149. title: {
  150. color: '#ffcccc',
  151. },
  152. title1: {
  153. color: '#ff4d4d',
  154. },
  155. title2: {
  156. color: '#4dd2ff',
  157. },
  158. title3: {
  159. color: '#ffff00',
  160. },
  161. }
  162. },
  163. splitLine: {
  164. show: false
  165. },
  166. axisTick: {
  167. show: false
  168. },
  169. axisLine: {
  170. show: false
  171. },
  172. data: getName
  173. }, {
  174. type: 'category',
  175. inverse: true,
  176. offset: -50,
  177. axisTick: 'none',
  178. axisLine: 'none',
  179. show: true,
  180. axisLabel: {
  181. textStyle: {
  182. color: '#ffffff',
  183. fontSize: '12'
  184. },
  185. },
  186. data: getValue
  187. }],
  188. series: [{
  189. name: '值',
  190. type: 'bar',
  191. zlevel: 1,
  192. itemStyle: {
  193. normal: {
  194. barBorderRadius: 30,
  195. // color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
  196. // offset: 0,
  197. // color: 'rgb(128,204,255,1)'
  198. // }, {
  199. // offset: 1,
  200. // color: 'rgb(46,200,207,1)'
  201. // }]),
  202. },
  203. },
  204. barWidth: 20,
  205. data: getValue
  206. },
  207. {
  208. name: '背景',
  209. type: 'bar',
  210. barWidth: 20,
  211. barGap: '-100%',
  212. data: getMax,
  213. itemStyle: {
  214. normal: {
  215. color: 'rgba(24,31,68,1)',
  216. barBorderRadius: 30,
  217. }
  218. },
  219. },
  220. ]
  221. };
  222. },
  223. }
  224. }
  225. </script>
  226. <style>
  227. </style>