chore: backup workspace before list detail shell refactor
This commit is contained in:
@@ -5,6 +5,12 @@ export function useEcharts(chartElement, chartOptions) {
|
||||
let chartInstance = null
|
||||
let resizeObserver = null
|
||||
let renderFrame = 0
|
||||
let initialFrame = 0
|
||||
let initialTimer = 0
|
||||
let initialRendered = false
|
||||
let initialPending = false
|
||||
let latestOption = null
|
||||
const initialAnimationDelay = 180
|
||||
|
||||
function renderChart() {
|
||||
if (!chartElement.value) {
|
||||
@@ -14,7 +20,37 @@ export function useEcharts(chartElement, chartOptions) {
|
||||
chartInstance = init(chartElement.value, null, { renderer: 'canvas' })
|
||||
chartInstance.resize()
|
||||
}
|
||||
chartInstance.setOption(chartOptions.value, true)
|
||||
|
||||
if (!initialRendered) {
|
||||
initialRendered = true
|
||||
initialPending = true
|
||||
latestOption = chartOptions.value
|
||||
if (typeof window !== 'undefined') {
|
||||
initialTimer = window.setTimeout(() => {
|
||||
initialTimer = 0
|
||||
initialFrame = window.requestAnimationFrame(() => {
|
||||
initialFrame = 0
|
||||
initialPending = false
|
||||
chartInstance?.setOption(latestOption || chartOptions.value, {
|
||||
notMerge: true,
|
||||
lazyUpdate: false
|
||||
})
|
||||
latestOption = null
|
||||
})
|
||||
}, initialAnimationDelay)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (initialPending) {
|
||||
latestOption = chartOptions.value
|
||||
return
|
||||
}
|
||||
|
||||
chartInstance.setOption(chartOptions.value, {
|
||||
notMerge: false,
|
||||
lazyUpdate: false
|
||||
})
|
||||
}
|
||||
|
||||
function handleResize() {
|
||||
@@ -63,6 +99,14 @@ export function useEcharts(chartElement, chartOptions) {
|
||||
window.cancelAnimationFrame(renderFrame)
|
||||
renderFrame = 0
|
||||
}
|
||||
if (initialFrame && typeof window !== 'undefined') {
|
||||
window.cancelAnimationFrame(initialFrame)
|
||||
initialFrame = 0
|
||||
}
|
||||
if (initialTimer && typeof window !== 'undefined') {
|
||||
window.clearTimeout(initialTimer)
|
||||
initialTimer = 0
|
||||
}
|
||||
if (chartInstance) {
|
||||
chartInstance.dispose()
|
||||
chartInstance = null
|
||||
|
||||
Reference in New Issue
Block a user