File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -21,21 +21,24 @@ const { width } = useElementSize(rootEl)
2121
2222const chartKey = ref (0 )
2323
24- function nextAnimationFrame(): Promise <void > {
25- return new Promise (resolve => {
26- requestAnimationFrame (() => resolve ())
27- })
28- }
24+ let chartRemountTimeoutId: ReturnType <typeof setTimeout > | null = null
2925
30- onMounted (async () => {
26+ onMounted (() => {
3127 rootEl .value = document .documentElement
3228 resolvedMode .value = colorMode .value === ' dark' ? ' dark' : ' light'
3329
3430 // If the chart is painted too early, built-in auto-sizing does not adapt to the final container size
35- await nextAnimationFrame ()
36- await nextAnimationFrame ()
37- await nextAnimationFrame ()
38- chartKey .value += 1
31+ chartRemountTimeoutId = setTimeout (() => {
32+ chartKey .value += 1
33+ chartRemountTimeoutId = null
34+ }, 10 )
35+ })
36+
37+ onBeforeUnmount (() => {
38+ if (chartRemountTimeoutId !== null ) {
39+ clearTimeout (chartRemountTimeoutId )
40+ chartRemountTimeoutId = null
41+ }
3942})
4043
4144const { colors } = useCssVariables (
You can’t perform that action at this time.
0 commit comments