Chartjs-SvelteKit: chartjs-plugin-zoom not working

0๐Ÿ‘

โœ…

1. Disable SSR for the page:
// +page.js
export const ssr = false;
2. import zoomPlugin normally.
<div>
    <canvas id="example"></canvas>
</div>

<script>
    import { onMount } from 'svelte'

    import Chart from 'chart.js/auto' // Version 4.3.3
    import zoomPlugin from "chartjs-plugin-zoom"

    Chart.register(zoomPlugin)

    onMount(() => {
        new Chart(
            document.getElementById('example'),
            { // From https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/usage.html
                ...
            }
        )
    })
</script>

Leave a comment