Skip to content

Commit f3e22f2

Browse files
authored
fix: wait more before re-rendering the chart (#623)
1 parent 5ec03c0 commit f3e22f2

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

app/components/PackageDownloadAnalytics.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ const { width } = useElementSize(rootEl)
2121
2222
const chartKey = ref(0)
2323
24+
function nextAnimationFrame(): Promise<void> {
25+
return new Promise(resolve => {
26+
requestAnimationFrame(() => resolve())
27+
})
28+
}
29+
2430
onMounted(async () => {
2531
rootEl.value = document.documentElement
2632
resolvedMode.value = colorMode.value === 'dark' ? 'dark' : 'light'
27-
requestAnimationFrame(() => {
28-
requestAnimationFrame(() => {
29-
chartKey.value += 1
30-
})
31-
})
33+
34+
// 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
3239
})
3340
3441
const { colors } = useCssVariables(

0 commit comments

Comments
 (0)