You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< script setup >
/**
* name:
* user: sa0ChunLuyu
* date: 2023年3月19日 14:53:06
*/
import {
onMounted ,
ref
} from 'vue'
import {
$response
} from '@/api'
import {
onShow
} from '@dcloudio/uni-app'
const props = defineProps ( {
option : {
type : Object ,
default : {
show : false ,
range : [ ] ,
min : 0 ,
max : 0
}
}
} ) ;
import * as echarts from 'echarts' ;
onMounted ( ( ) => {
drawChart ( )
} )
const drawChart = ( ) => {
var chartDom = document . getElementById ( 'main' ) ;
var myChart = echarts . init ( chartDom ) ;
var option ;
let width = 12
let label _arr = [ ]
option = {
series : [ {
type : 'gauge' ,
min : Number ( props . option . range [ 0 ] . value ) ,
max : Number ( props . option . range [ props . option . range . length - 1 ] . value ) ,
startAngle : 135 ,
endAngle : - 150 ,
axisLine : {
lineStyle : {
width : width ,
color : props . option . range . map ( ( item ) => {
return [ item . percent , item . color ]
} )
}
} ,
pointer : {
width : 5 ,
length : '80%' ,
itemStyle : {
color : 'inherit'
}
} ,
axisTick : {
distance : - width ,
length : 3 ,
lineStyle : {
color : '#fff' ,
width : 1
}
} ,
splitLine : {
distance : - width ,
length : width ,
lineStyle : {
color : '#fff' ,
width : 1
}
} ,
axisLabel : {
color : '#333333' ,
distance : 14 ,
fontSize : 8 ,
formatter : ( value ) => {
let label _str = ''
for ( let i in props . option . range ) {
if ( Number ( i ) === 0 ) continue ;
if ( value >= props . option . range [ Number ( i ) - 1 ] . value && value < props
. option . range [ Number ( i ) ] . value ) {
if ( label _arr . length < i ) {
label _arr . push ( 0 )
return props . option . label [ i - 1 ]
} else {
continue
}
} else {
continue
}
}
return label _str ;
}
} ,
detail : {
formatter : '{value}' ,
color : 'inherit' ,
fontSize : 9
} ,
data : [ {
value : Number ( props . option . value )
} ]
} ]
} ;
option && myChart . setOption ( option ) ;
}
< / script >
< template >
< view >
< div class = "chart_wrapper" id = "main" > < / div >
< / view >
< / template >
< style scoped >
. chart _wrapper {
width : 294 rpx ;
line - height : 294 rpx ;
height : 338 rpx ;
text - align : center ;
transform : scale ( 1.3 ) ;
}
< / style >