8.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div id="myChartindex8" 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: '67%',
  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: this.fontSize(0.20),
  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. console.log(result,"0000");
  75. this.data1 = result.data1;
  76. this.data2 = result.data2;
  77. this.data3 = result.data3;
  78. this.data4 = result.data4;
  79. const seriesArr = [];
  80. const liquidFill4 = this.createLiquidfill({ index: 3, center_x: 46, center_y: 55, text: this.data4.value, value: this.handlerData(this.data4.value) });
  81. seriesArr.push(liquidFill4);
  82. if(this.myChart != null) {
  83. this.myChart.clear();
  84. }
  85. this.myChart = this.$echarts.init(document.getElementById('myChartindex8'));
  86. this.myChart.setOption({
  87. grid:{
  88. left:"2%"
  89. },
  90. xAxis: {
  91. type: 'value',
  92. max: 100,
  93. splitLine: {
  94. show: false
  95. },
  96. axisLine: {
  97. show: false
  98. },
  99. axisLabel: {
  100. show: false
  101. },
  102. axisTick: {
  103. show: false
  104. }
  105. },
  106. yAxis: {
  107. type: 'category',
  108. splitLine: {
  109. show: false
  110. },
  111. axisLine: {
  112. show: false
  113. },
  114. axisLabel: {
  115. show: false
  116. },
  117. axisTick: {
  118. show: false
  119. }
  120. },
  121. series: seriesArr
  122. });
  123. },
  124. fontSize(res) {
  125. let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  126. if (!clientWidth) return;
  127. let fontSize = 100 * (clientWidth / 1920);
  128. return res * fontSize;
  129. }
  130. },
  131. mounted() {
  132. // this.draw();
  133. }
  134. }
  135. </script>
  136. <style scoped>
  137. </style>