as many know Chart.js is used to render charts to the DOM (not directly). its api is simple, an instance of Chart class is initiated by passing a DOM node (which must be a canva element) and data that used to draw the chart as arguments. Difficult part is that rendering of the html happens during the build stage on server where document object is not available and I cannot hook to any of the DOM elements that I have on the client.
Of course I can use Chart.js on the client inside script section but then it will import the whole chart.js library everytime the user uses the app and start drawing charts on the client which may take some time so I was wondering what are proven strategies in this kind of situations when you don't have access to the DOM elements that you need but don't want to compromise on moving everything to the client?
#is it possible to use Chart.js when using SSR?
1 messages · Page 1 of 1 (latest)
Thank you
May I ask you how did you achieve chartjs working at build time?