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:22
*/
import {
ref ,
onMounted
} from 'vue'
import {
$response
} from '@/api'
import {
onShow
} from '@dcloudio/uni-app'
const props = defineProps ( {
option : {
type : Object ,
default : {
show : false ,
data : [ ] ,
min : 0 ,
max : 0 ,
unit : '' ,
}
}
} ) ;
import * as echarts from 'echarts' ;
onMounted ( ( ) => {
drawChart ( )
} )
const drawChart = ( ) => {
let chartDom = document . getElementById ( 'line' ) ;
let myChart = echarts . init ( chartDom ) ;
let option ;
let xy _option = {
axisLabel : {
fontWeight : 'bold' ,
textStyle : {
color : "#333333" ,
} ,
} ,
axisLine : {
show : true ,
lineStyle : {
color : "#799abb" ,
width : 2 ,
type : "solid"
} ,
}
}
let data = [ ]
for ( let i in props . option . data ) {
data . push ( [ i , props . option . data [ i ] . value ] )
}
option = {
xAxis : {
min : 0 ,
max : props . option . data . length - 1 ,
interval : 1 ,
... xy _option ,
axisLabel : {
formatter : function ( value ) {
return props . option . data [ Number ( value ) ] ? . datetime . split ( '-' ) . join ( '.' )
} ,
}
} ,
yAxis : {
interval : Number ( props . option . step ) ,
min : Number ( props . option . min ) ,
max : Number ( props . option . max ) ,
... xy _option
} ,
lineStyle : {
color : '#e13327'
} ,
grid : {
x : "12%" ,
y : "7%" ,
height : "79%" // 高度
} ,
series : [ {
symbol : 'circle' ,
symbolSize : 6 ,
itemStyle : {
color : '#e13327' ,
} ,
markLine : {
data : [ {
symbolSize : 6 ,
label : {
color : '#b2a4e4'
} ,
lineStyle : {
color : '#b2a4e4'
} ,
name : 'yo' ,
yAxis : Number ( props . option . range [ 0 ] ) ,
} , {
symbolSize : 6 ,
label : {
color : '#65c1c2'
} ,
lineStyle : {
color : '#65c1c2'
} ,
name : 'yo' ,
yAxis : Number ( props . option . range [ 1 ] ) ,
} ]
} ,
data : data ,
type : 'line'
} ] ,
} ;
option && myChart . setOption ( option ) ;
}
< / script >
< template >
< view >
< view class = "unit_wrapper" > 单位 : { { props . option . unit } } < / view >
< view class = "chart_wrapper" id = "line" > 折线图 < / view >
< / view >
< / template >
< style scoped >
. unit _wrapper {
margin - left : 134 rpx ;
margin - top : 44 rpx ;
font - size : 22 rpx ;
font - weight : 500 ;
color : # 939898 ;
line - height : 1 ;
}
. chart _wrapper {
width : 591 rpx ;
height : 392 rpx ;
line - height : 392 rpx ;
text - align : center ;
margin : 7 rpx auto 0 ;
}
< / style >