[Chartjs]-Chartjs chart broke when using Pagedjs

1👍

I found a solution to this after help by the good people at https://pagedjs.org/

<head>
    <script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
</head>

Now in your body, add the following Paged.js extension:

<body>
<div id="yourchart"></div>
<script>

  class myChartCreator extends Paged.Handler {
            constructor(chunker, polisher, caller) {
                super(chunker, polisher, caller);
            }

            afterRendered(pages) {
               loadYourChart();
               someOtherFunction();
               return Promise.resolve(
                    someLongRunningStuff()
               );
               ...
             }
        }
        Paged.registerHandlers(myChartCreator);

</script>
</body>

It works perfectly with both Chart.js and amcharts5.

Leave a comment