5.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div id="myChartindex5" style="width: 100%; height: 100%; "></div>
  3. </template>
  4. <script>
  5. import { fourquan } from '../../api'
  6. import 'echarts-liquidfill'
  7. export default {
  8. name: "OperationAnalysisCount",
  9. data() {
  10. return {
  11. data1: { label: '巡访平均周期', value: '3.5天' },
  12. data2: { label: '子女绑定占比', value: '60%' },
  13. data3: { label: '积分存量', value: 123156 },
  14. data4: { label: '兑换比例', value: '60%' },
  15. colorArr: [
  16. { color1: '#ff8d00', color2: '#FFF43F' },
  17. { color1: '#5fff06', color2: '#B4FF9F' },
  18. { color1: '#60b8db', color2: '#afd3ff' },
  19. { color1: '#ff00e8', color2: '#f48fff' }
  20. ],
  21. myChart: null
  22. }
  23. },
  24. methods: {
  25. handlerData(val) {
  26. const length = String(parseInt(val)).length;
  27. let r = 1;
  28. if(length != 0) {
  29. r = r + new Array(length).fill(0).join('');
  30. }
  31. return (parseInt(val) / parseInt(r)).toFixed(2);
  32. },
  33. createLiquidfill(obj) {
  34. return {
  35. type: 'liquidFill',
  36. data: [obj.value],
  37. radius: '30%',
  38. center: [`${obj.center_x}%`, `${obj.center_y}%`],
  39. outline: {
  40. show: false
  41. },
  42. backgroundStyle: {
  43. borderWidth: 0,
  44. color: "transparent"
  45. },
  46. waveAnimation: false, // 禁止左右波动
  47. label: {
  48. normal: {
  49. position: ['50%', '53%'],
  50. textStyle: {
  51. fontSize: 24,
  52. color: '#fff'
  53. },
  54. formatter: `${ obj.text }`
  55. }
  56. },
  57. itemStyle: {
  58. normal: {
  59. color: new this.$echarts.graphic.LinearGradient(
  60. 0, 0, 0, 1,
  61. [
  62. {offset: 0, color: this.colorArr[obj.index].color1},
  63. {offset: 1, color: this.colorArr[obj.index].color2}
  64. ]
  65. )
  66. }
  67. }
  68. };
  69. },
  70. createCircleImage(){
  71. },
  72. async draw() {
  73. const result = await fourquan({}, 'POST');
  74. this.data1 = result.data1;
  75. this.data2 = result.data2;
  76. this.data3 = result.data3;
  77. this.data4 = result.data4;
  78. const seriesArr = [];
  79. const liquidFill1 = this.createLiquidfill({ index: 0, center_x: 13, center_y: 30, text: this.data1.value, value: this.handlerData(this.data1.value) });
  80. seriesArr.push(liquidFill1);
  81. const liquidFill2 = this.createLiquidfill({ index: 1, center_x: 53, center_y: 28, text: this.data2.value + '%', value: this.handlerData(this.data2.value + '%') });
  82. seriesArr.push(liquidFill2);
  83. const liquidFill3 = this.createLiquidfill({ index: 2, center_x: 13, center_y: 75, text: this.data3.value, value: this.handlerData(this.data3.value) });
  84. seriesArr.push(liquidFill3);
  85. const liquidFill4 = this.createLiquidfill({ index: 3, center_x: 53, center_y: 75, text: this.data4.value, value: this.handlerData(this.data4.value) });
  86. seriesArr.push(liquidFill4);
  87. seriesArr.push({
  88. type: 'pictorialBar',
  89. symbol: `image://${require('../../assets/index/liquidfill-1-circle.png')}`,
  90. symbolSize: [102, 102],
  91. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [10, -100] }, {}],
  92. label: {
  93. show: true,
  94. position: 'top',
  95. offset: [-80, -80],
  96. color: '#fff',
  97. fontSize: 16,
  98. formatter: '巡访平均周期'
  99. },
  100. z: 2
  101. });
  102. seriesArr.push({
  103. type: 'pictorialBar',
  104. symbol: `image://${require('../../assets/index/liquidfill-1-line.png')}`,
  105. symbolSize: [62, 5],
  106. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [120, -60] }, {}],
  107. label: {
  108. show: true,
  109. position: 'top',
  110. offset: [-90, -45],
  111. color: this.colorArr[0].color1,
  112. fontSize: 16,
  113. formatter: this.data1.value
  114. },
  115. z: 2
  116. });
  117. seriesArr.push({
  118. type: 'pictorialBar',
  119. symbol: `image://${require('../../assets/index/liquidfill-2-circle.png')}`,
  120. symbolSize: [102, 102],
  121. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [230, -100] }, {}],
  122. label: {
  123. show: true,
  124. position: 'top',
  125. offset: [140, -80],
  126. color: '#fff',
  127. fontSize: 16,
  128. formatter: '子女绑定占比'
  129. },
  130. z: 2
  131. });
  132. seriesArr.push({
  133. type: 'pictorialBar',
  134. symbol: `image://${require('../../assets/index/liquidfill-2-line.png')}`,
  135. symbolSize: [62, 5],
  136. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [340, -60] }, {}],
  137. label: {
  138. show: true,
  139. position: 'top',
  140. offset: [130, -45],
  141. color: this.colorArr[1].color1,
  142. fontSize: 16,
  143. formatter: `${this.data2.value}%`
  144. },
  145. z: 2
  146. });
  147. seriesArr.push({
  148. type: 'pictorialBar',
  149. symbol: `image://${require('../../assets/index/liquidfill-3-circle.png')}`,
  150. symbolSize: [102, 102],
  151. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [10, 30] }, {}],
  152. label: {
  153. show: true,
  154. position: 'top',
  155. offset: [-90, 55],
  156. color: '#fff',
  157. fontSize: 16,
  158. formatter: '积分存量'
  159. },
  160. z: 2
  161. });
  162. seriesArr.push({
  163. type: 'pictorialBar',
  164. symbol: `image://${require('../../assets/index/liquidfill-3-line.png')}`,
  165. symbolSize: [62, 5],
  166. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [120, 70] }, {}],
  167. label: {
  168. show: true,
  169. position: 'top',
  170. offset: [-90, 90],
  171. color: this.colorArr[2].color1,
  172. fontSize: 16,
  173. formatter: `${this.data3.value}`
  174. },
  175. z: 2
  176. });
  177. seriesArr.push({
  178. type: 'pictorialBar',
  179. symbol: `image://${require('../../assets/index/liquidfill-4-circle.png')}`,
  180. symbolSize: [102, 102],
  181. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [230, 30] }, {}],
  182. label: {
  183. show: true,
  184. position: 'top',
  185. offset: [130, 55],
  186. color: '#fff',
  187. fontSize: 16,
  188. formatter: '兑换比例'
  189. },
  190. z: 2
  191. });
  192. seriesArr.push({
  193. type: 'pictorialBar',
  194. symbol: `image://${require('../../assets/index/liquidfill-4-line.png')}`,
  195. symbolSize: [62, 5],
  196. data: [{ value: 100, symbolPosition: 'start', symbolOffset: [340, 70] }, {}],
  197. label: {
  198. show: true,
  199. position: 'top',
  200. offset: [130, 90],
  201. color: this.colorArr[3].color1,
  202. fontSize: 16,
  203. formatter: `${this.data4.value}`
  204. },
  205. z: 2
  206. });
  207. if(this.myChart != null) {
  208. this.myChart.clear();
  209. }
  210. this.myChart = this.$echarts.init(document.getElementById('myChartindex5'));
  211. this.myChart.setOption({
  212. grid:{
  213. left:"2%"
  214. },
  215. xAxis: {
  216. type: 'value',
  217. max: 100,
  218. splitLine: {
  219. show: false
  220. },
  221. axisLine: {
  222. show: false
  223. },
  224. axisLabel: {
  225. show: false
  226. },
  227. axisTick: {
  228. show: false
  229. }
  230. },
  231. yAxis: {
  232. type: 'category',
  233. splitLine: {
  234. show: false
  235. },
  236. axisLine: {
  237. show: false
  238. },
  239. axisLabel: {
  240. show: false
  241. },
  242. axisTick: {
  243. show: false
  244. }
  245. },
  246. series: seriesArr
  247. });
  248. }
  249. },
  250. mounted() {
  251. this.draw();
  252. }
  253. }
  254. </script>
  255. <style scoped>
  256. </style>