123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <template>
- <mx-echarts :option="option" canvas-id="accuracy-chart"/>
- </template>
- <script>
- export default {
- name: "accuracy-chart",
- props: {
- value: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- option: null
- }
- },
- watch: {
- value: function () {
- this.updateOption()
- }
- },
- mounted() {
- this.updateOption()
- },
- methods: {
- updateOption() {
- const gaugeData = [{
- value: this.value,
- name: '正确率',
- title: {
- offsetCenter: ['0%', '-22%'],
- fontSize: 14,
- },
- detail: {
- valueAnimation: true,
- offsetCenter: ['0%', '16%'],
- fontSize: 28,
- borderWidth: 0,
- color: '#333',
- formatter: function (val) {
- if ([null, undefined, NaN].includes(val)) return '暂无'
- return val + '%'
- }
- }
- }];
- this.option = {
- series: [{
- type: 'gauge',
- radius: '70%',
- startAngle: 90,
- endAngle: -270,
- pointer: {
- show: false
- },
- progress: {
- show: ![null, undefined, NaN].includes(this.value),
- overlap: false,
- roundCap: true,
- clip: false,
- itemStyle: {
- color: {
- type: 'radial',
- x: 0,
- y: 0,
- r: 1.2,
- colorStops: [{
- offset: 0,
- color: '#67B9F5'
- }, {
- offset: 1,
- color: '#4F87FC'
- }],
- }
- }
- },
- axisLine: {
- lineStyle: {
- width: 16
- }
- },
- splitLine: {
- show: false,
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false,
- },
- data: gaugeData
- }]
- }
- }
- }
- }
- </script>
- <style scoped>
- </style>
|