PanelGroups.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div :class="className" :style="{ height: height, width: width }" />
  3. </template>
  4. <script>
  5. import echarts from 'echarts';
  6. require('echarts/theme/macarons'); // echarts theme
  7. import resize from './mixins/resize';
  8. export default {
  9. mixins: [resize],
  10. props: {
  11. className: {
  12. type: String,
  13. default: 'chart'
  14. },
  15. width: {
  16. type: String,
  17. default: '150px'
  18. },
  19. height: {
  20. type: String,
  21. default: '150px'
  22. },
  23. autoResize: {
  24. type: Boolean,
  25. default: true
  26. },
  27. chartData: {
  28. type: Object,
  29. required: true
  30. }
  31. },
  32. data() {
  33. return {
  34. chart: null
  35. };
  36. },
  37. watch: {
  38. chartData: {
  39. deep: true,
  40. handler(val) {
  41. this.setOptions(val)
  42. }
  43. }
  44. },
  45. mounted() {
  46. this.$nextTick(() => {
  47. this.initChart();
  48. });
  49. console.log(this.chartData,58)
  50. },
  51. beforeDestroy() {
  52. if (!this.chart) {
  53. return;
  54. }
  55. this.chart.dispose();
  56. this.chart = null;
  57. },
  58. methods: {
  59. initChart() {
  60. this.chart = echarts.init(this.$el, 'macarons');
  61. this.chart = echarts.init(this.$el, 'macarons')
  62. this.setOptions(this.chartData)
  63. console.log(this.chartData)
  64. },
  65. setOptions({ reportQueryLogNum, reportQueryLogTodayNum,reportQueryLog} = {}) {
  66. // console.log(inspectNum, inspectTodayNum,inspect)
  67. this.chart.setOption({
  68. color: [new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  69. offset: 0,
  70. color: '#50BD04'
  71. },
  72. {
  73. offset: 1,
  74. color: '#50BD04'
  75. }]), new echarts.graphic.LinearGradient(1, 1, 0, 0, [{
  76. offset: 0,
  77. color: '#C8E1B6'
  78. },
  79. {
  80. offset: 0.9,
  81. color: '#C8E1B6'
  82. }]),],
  83. tooltip: {
  84. trigger: 'item'
  85. },
  86. legend: {
  87. top: '10%',
  88. left: 'center',
  89. data:[]
  90. },
  91. // 设置环形中间的数据
  92. graphic: [{
  93. type: 'text',
  94. left: 'center',
  95. top: '46%',
  96. z: 10,
  97. style: {
  98. fill: '#50BD04',
  99. text: reportQueryLog,
  100. // lmrszb
  101. font: '16px Microsoft YaHei'
  102. },
  103. textStyle: {
  104. color: "#50BD04",
  105. fontSize: 17,
  106. align: "center"
  107. }
  108. }],
  109. series: [
  110. {
  111. name: '查询次数',
  112. type: 'pie',
  113. radius: ['55%', '70%'],
  114. center: ['center', '50%'],
  115. avoidLabelOverlap: false,
  116. // label: {
  117. // show: false,
  118. // position: 'center'
  119. // },
  120. // emphasis: {
  121. // label: {
  122. // show: true,
  123. // fontSize: '17',
  124. // fontWeight: '400',
  125. // color:'#2497D5'
  126. // }
  127. // },
  128. // labelLine: {
  129. // show: true
  130. // },
  131. itemStyle: {
  132. normal: {
  133. label: {
  134. show: false
  135. },
  136. labelLine: {
  137. show: false
  138. }
  139. },
  140. emphasis: {
  141. label: {
  142. show: false,
  143. position: 'outer',
  144. textStyle: {
  145. fontSize: '15',
  146. fontWeight: 'bold',
  147. color: 'white'
  148. }
  149. }
  150. }
  151. },
  152. data: [
  153. // {value: lmrs, name: '绿码人数'},
  154. // {value:jrsmrc, name: '扫码人数'}
  155. {value: reportQueryLogNum, name: '总计查询次数'},
  156. {value:reportQueryLogTodayNum, name: '今日查询次数'}
  157. ]
  158. }
  159. ]
  160. })
  161. }
  162. }
  163. };
  164. </script>