|
@@ -61,6 +61,8 @@ const trendChartRef = ref<HTMLDivElement>()
|
|
|
let distributionChart: echarts.ECharts | null = null
|
|
let distributionChart: echarts.ECharts | null = null
|
|
|
let trendChart: echarts.ECharts | null = null
|
|
let trendChart: echarts.ECharts | null = null
|
|
|
let distributionResizeObserver: ResizeObserver | null = null
|
|
let distributionResizeObserver: ResizeObserver | null = null
|
|
|
|
|
+let trendResizeObserver: ResizeObserver | null = null
|
|
|
|
|
+let trendResizeFrame: number | null = null
|
|
|
|
|
|
|
|
const panelOptions: Array<{ label: string; value: ActivePanel }> = [
|
|
const panelOptions: Array<{ label: string; value: ActivePanel }> = [
|
|
|
{ label: '存货分布', value: 'distribution' },
|
|
{ label: '存货分布', value: 'distribution' },
|
|
@@ -532,7 +534,7 @@ function initTrendChart() {
|
|
|
|
|
|
|
|
function resizeCharts() {
|
|
function resizeCharts() {
|
|
|
distributionChart?.resize()
|
|
distributionChart?.resize()
|
|
|
- trendChart?.resize()
|
|
|
|
|
|
|
+ scheduleTrendResize()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function handleDistributionResize() {
|
|
function handleDistributionResize() {
|
|
@@ -542,6 +544,19 @@ function handleDistributionResize() {
|
|
|
renderDistributionChart()
|
|
renderDistributionChart()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function scheduleTrendResize() {
|
|
|
|
|
+ if (trendResizeFrame !== null) return
|
|
|
|
|
+
|
|
|
|
|
+ trendResizeFrame = requestAnimationFrame(() => {
|
|
|
|
|
+ trendResizeFrame = null
|
|
|
|
|
+ if (activePanel.value !== 'trend' || !trendChartRef.value) return
|
|
|
|
|
+
|
|
|
|
|
+ if (!trendChart) initTrendChart()
|
|
|
|
|
+ trendChart?.resize()
|
|
|
|
|
+ renderTrendChart()
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function destroyCharts() {
|
|
function destroyCharts() {
|
|
|
distributionChart?.dispose()
|
|
distributionChart?.dispose()
|
|
|
trendChart?.dispose()
|
|
trendChart?.dispose()
|
|
@@ -635,6 +650,8 @@ onMounted(() => {
|
|
|
initDistributionChart()
|
|
initDistributionChart()
|
|
|
distributionResizeObserver = new ResizeObserver(handleDistributionResize)
|
|
distributionResizeObserver = new ResizeObserver(handleDistributionResize)
|
|
|
distributionResizeObserver.observe(distributionChartRef.value!)
|
|
distributionResizeObserver.observe(distributionChartRef.value!)
|
|
|
|
|
+ trendResizeObserver = new ResizeObserver(scheduleTrendResize)
|
|
|
|
|
+ trendResizeObserver.observe(trendChartRef.value!)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
window.addEventListener('resize', resizeCharts)
|
|
window.addEventListener('resize', resizeCharts)
|
|
@@ -662,6 +679,12 @@ onUnmounted(() => {
|
|
|
window.removeEventListener('rhkb:resize', resizeCharts)
|
|
window.removeEventListener('rhkb:resize', resizeCharts)
|
|
|
distributionResizeObserver?.disconnect()
|
|
distributionResizeObserver?.disconnect()
|
|
|
distributionResizeObserver = null
|
|
distributionResizeObserver = null
|
|
|
|
|
+ trendResizeObserver?.disconnect()
|
|
|
|
|
+ trendResizeObserver = null
|
|
|
|
|
+ if (trendResizeFrame !== null) {
|
|
|
|
|
+ cancelAnimationFrame(trendResizeFrame)
|
|
|
|
|
+ trendResizeFrame = null
|
|
|
|
|
+ }
|
|
|
destroyCharts()
|
|
destroyCharts()
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|