apexcharts / ng-apexcharts

ng-apexcharts is an implementation of apexcharts for angular. It comes with one simple component that enables you to use apexcharts in an angular project.
MIT License
321 stars 80 forks source link

ReferenceError: window is not defined #166

Closed muzafferAyd closed 4 months ago

muzafferAyd commented 3 years ago

Hi, While using apexchart with SSR angular Universal, always this error occurs. ReferenceError: window is not defined

When ng serve , there is no problem, all things work. But when I run "build:ssr" then "serve:ssr" there is a window defination problem. Could you help me please ?

package.json: "apexcharts": "^3.29.0", "ng-apexcharts": "^1.5.0", "@nguniversal/express-engine": "^10.1.0", "@angular/compiler": "~10.2.4", "@angular/core": "~10.2.4",

I also added below code in angular.json

        "scripts": [
          "node_modules/apexcharts/dist/apexcharts.min.js"
        ]
pablodorao commented 12 months ago

Hello, I wanted to know if ng-apexcharts supports angular universal SSR?, since I am presenting the same error "ReferenceError: window is not defined."

offline: Failure: window is not defined ReferenceError: window is not defined

"dependencies": { "@agm/core": "^3.0.0-beta.0", "@angular/animations": "~13.4.0", "@angular/cdk": "^13.3.9", "@angular/common": "~13.4.0", "@angular/compiler": "~13.4.0", "@angular/core": "~13.4.0", "@angular/flex-layout": "^11.0.0-beta.33", "@angular/forms": "~13.4.0", "@angular/material": "^13.3.9", "@angular/platform-browser": "~13.4.0", "@angular/platform-browser-dynamic": "~13.4.0", "@angular/platform-server": "~13.4.0", "@angular/router": "~13.4.0", "@angular/service-worker": "13.4.0", "@auth0/angular-jwt": "^5.0.2", "@gorniv/ngx-universal": "2.2.2", "@ionic/angular": "^5.5.1", "@ngrx/store": "^11.1.1", "@nguniversal/common": "13.1.1", "@nguniversal/express-engine": "^13.1.1", "@ngx-meta/core": "^9.0.0", "@vendia/serverless-express": "^4.3.11", "angular-l10n": "^11.0.0", "apexcharts": "^3.41.0", "aws-serverless-express": "^3.3.8", "concurrently": "^5.3.0", "cookie-parser": "1.4.5", "core-js": "3.7.0", "express": "^4.15.2", "html2canvas": "^1.4.1", "moment": "^2.29.1", "ng-apexcharts": "^1.7.7", "node-cache": "5.1.2", "query-string": "^6.13.7", "reflect-metadata": "0.1.13", "rxjs": "^6.5.5", "rxjs-tslint": "0.1.8", "serverless": "^1.80.0", "serverless-apigw-binary": "^0.4.4", "serverless-offline": "^6.7.0", }, Could you help me please ?

Regards.

thienkonphap commented 10 months ago

Hello is there any update on this? . I'm facing the same problem: window is not defined

i'm using Angular 17

Thank you

LuisUcla commented 10 months ago

Hello, I also have the same error: window is not defined. With other chart libraries, for example ngx-charts for Angular, I don't get this error.

zmmfa commented 6 months ago

Hello,

Same here with angular 17 and ssr enabled:

[vite] Internal server error: window is not defined at node_modules/apexcharts/dist/apexcharts.common.js (/.../node_modules/apexcharts/dist/apexcharts.common.js:6:391309)