|
|
|
@ -84,7 +84,7 @@ |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import * as echarts from 'echarts' |
|
|
|
import {onMounted, onUnmounted, ref, watch} from 'vue' |
|
|
|
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue' |
|
|
|
import API from '@/util/http' |
|
|
|
import {ElMessage} from 'element-plus' |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
@ -150,9 +150,9 @@ const length = ref(0) |
|
|
|
const chartLoading = ref(true) |
|
|
|
|
|
|
|
const handleResize = () => { |
|
|
|
if (chartInstance.value) { |
|
|
|
if (chartInstance) { |
|
|
|
try { |
|
|
|
chartInstance.value.resize() |
|
|
|
chartInstance.resize() |
|
|
|
console.log('resize一下') |
|
|
|
} catch (error) { |
|
|
|
console.error('图表resize失败:', error) |
|
|
|
@ -168,13 +168,13 @@ const initChart = () => { |
|
|
|
} |
|
|
|
// 销毁图表 |
|
|
|
const destroyChart = () => { |
|
|
|
if (chartInstance.value) { |
|
|
|
if (chartInstance) { |
|
|
|
try { |
|
|
|
chartInstance.value.dispose() |
|
|
|
chartInstance.dispose() |
|
|
|
} catch (error) { |
|
|
|
console.error('图表销毁失败:', error) |
|
|
|
} |
|
|
|
chartInstance.value = null |
|
|
|
chartInstance = null |
|
|
|
} |
|
|
|
window.removeEventListener('resize', handleResize) |
|
|
|
} |
|
|
|
@ -519,6 +519,7 @@ const updateChart = (chartData) => { |
|
|
|
if (!chartInstance) { |
|
|
|
initChart() |
|
|
|
} |
|
|
|
if (!chartInstance) return |
|
|
|
chartLoading.value = true |
|
|
|
try { |
|
|
|
let series = [] |
|
|
|
@ -686,10 +687,9 @@ const handleDatePickerChange = () => { |
|
|
|
onMounted(async () => { |
|
|
|
await getAdminData() |
|
|
|
await getMarkets() |
|
|
|
await nextTick() |
|
|
|
initChart() |
|
|
|
getYear() |
|
|
|
window.addEventListener('resize', () => { |
|
|
|
chartInstance.resize() |
|
|
|
}) |
|
|
|
}) |
|
|
|
onUnmounted(() => { |
|
|
|
destroyChart() |
|
|
|
|