实时数据-数据更新闪动问题修改

This commit is contained in:
zhujiyan
2024-10-21 10:08:05 +08:00
parent 9ec4a8676c
commit 382085c514
2 changed files with 33 additions and 26 deletions

View File

@@ -20,7 +20,7 @@ const config = useConfig()
color[0] = config.layout.elementUiPrimary[0]
const chartRef = ref<HTMLDivElement>()
const props = defineProps(['options','isInterVal'])
const props = defineProps(['options', 'isInterVal', 'pieInterVal'])
let chart: echarts.ECharts | any = null
const resizeHandler = () => {
// 不在视野中的时候不进行resize
@@ -33,8 +33,8 @@ const resizeHandler = () => {
})
}
const initChart = () => {
if(!props.isInterVal){
chart?.dispose()
if (!props.isInterVal && !props.pieInterVal) {
chart?.dispose()
}
// chart?.dispose()
chart = echarts.init(chartRef.value as HTMLDivElement)
@@ -111,6 +111,7 @@ const initChart = () => {
handlerBar(options)
// 处理柱状图
chart.setOption(options)
setTimeout(() => {
chart.resize()
}, 0)
@@ -146,7 +147,7 @@ const handlerYAxis = () => {
nameTextStyle: {
color: '#000'
},
splitNumber:5,
splitNumber: 5,
minInterval: 1,
axisLine: {
show: true,
@@ -158,7 +159,7 @@ const handlerYAxis = () => {
color: '#000',
fontSize: 14,
formatter: function (value) {
return value.toFixed(0); // 格式化显示为一位小数
return value.toFixed(0) // 格式化显示为一位小数
}
},
splitLine: {
@@ -168,8 +169,7 @@ const handlerYAxis = () => {
type: 'dashed',
opacity: 0.5
}
},
}
}
// props.options?.xAxis 是数组还是对象
if (Array.isArray(props.options?.yAxis)) {
@@ -199,11 +199,9 @@ const handlerXAxis = () => {
// textStyle: {
fontFamily: 'dinproRegular',
color: '#000',
fontSize: '12',
fontSize: '12'
// }
}
}
// props.options?.xAxis 是数组还是对象
if (Array.isArray(props.options?.xAxis)) {
@@ -244,7 +242,7 @@ onBeforeUnmount(() => {
watch(
() => props.options,
(newVal, oldVal) => {
initChart()
initChart()
}
)
</script>