accuracy-chart.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <mx-echarts :option="option" canvas-id="accuracy-chart"/>
  3. </template>
  4. <script>
  5. export default {
  6. name: "accuracy-chart",
  7. props: {
  8. value: {
  9. type: Number,
  10. default: 0
  11. }
  12. },
  13. data() {
  14. return {
  15. option: null
  16. }
  17. },
  18. watch: {
  19. value: function () {
  20. this.updateOption()
  21. }
  22. },
  23. mounted() {
  24. this.updateOption()
  25. },
  26. methods: {
  27. updateOption() {
  28. const gaugeData = [{
  29. value: this.value,
  30. name: '正确率',
  31. title: {
  32. offsetCenter: ['0%', '-22%'],
  33. fontSize: 14,
  34. },
  35. detail: {
  36. valueAnimation: true,
  37. offsetCenter: ['0%', '16%'],
  38. fontSize: 28,
  39. borderWidth: 0,
  40. color: '#333',
  41. formatter: function (val) {
  42. if ([null, undefined, NaN].includes(val)) return '暂无'
  43. return val + '%'
  44. }
  45. }
  46. }];
  47. this.option = {
  48. series: [{
  49. type: 'gauge',
  50. radius: '70%',
  51. startAngle: 90,
  52. endAngle: -270,
  53. pointer: {
  54. show: false
  55. },
  56. progress: {
  57. show: ![null, undefined, NaN].includes(this.value),
  58. overlap: false,
  59. roundCap: true,
  60. clip: false,
  61. itemStyle: {
  62. color: {
  63. type: 'radial',
  64. x: 0,
  65. y: 0,
  66. r: 1.2,
  67. colorStops: [{
  68. offset: 0,
  69. color: '#67B9F5'
  70. }, {
  71. offset: 1,
  72. color: '#4F87FC'
  73. }],
  74. }
  75. }
  76. },
  77. axisLine: {
  78. lineStyle: {
  79. width: 16
  80. }
  81. },
  82. splitLine: {
  83. show: false,
  84. },
  85. axisTick: {
  86. show: false
  87. },
  88. axisLabel: {
  89. show: false,
  90. },
  91. data: gaugeData
  92. }]
  93. }
  94. }
  95. }
  96. }
  97. </script>
  98. <style scoped>
  99. </style>