I would like to use apexcharts and ng-apexcharts in angular 18 with SSR , i have this problem:
window is not defined
at node_modules/apexcharts/dist/apexcharts.common.js (c:/Users/lakhm/Desktop/cod_manager/node_modules/apexcharts/dist/apexcharts.common.js:6:398992)
at __require2 (C:/Users/lakhm/Desktop/cod_manager/.angular/vite-root/cod_manager/chunk-IOFBTDQ2.mjs:47:50)
at eval (c:/Users/lakhm/Desktop/cod_manager/node_modules/ng-apexcharts/fesm2020/ng-apexcharts.mjs:4:24)
at async instantiateModule (file:///C:/Users/lakhm/Desktop/cod_manager/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:55058:9
help me as soon as possible
adam lakhmiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
window
and document
does not exist on the server. So when you use SSR in your angular application. The code rendering on the server has window
as undefined
. To solve this. Write your Chart code inside the hook afterRender
...
afterRender() {
// write your chart code here!
}
...