Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR TypeError: Cannot read properties of undefined (reading 'Core/Globals.js') #372

Open
borisdaev opened this issue Feb 22, 2024 · 2 comments
Labels

Comments

@borisdaev
Copy link

borisdaev commented Feb 22, 2024

code

line-chart.component.ts

import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { HighchartsChartModule } from 'highcharts-angular';
// import * as Highcharts from 'highcharts/highstock';
import Highcharts from 'highcharts';
import HC_Stock from 'highcharts/modules/stock';
HC_Stock(Highcharts);

@component({
selector: "app-line-chart",
standalone:true,
templateUrl: "./line-chart.component.html",
styleUrls: ["./line-chart.component.scss"],
imports:[CommonModule, HighchartsChartModule]
})
export class LineChartComponent{
Highcharts: typeof Highcharts = Highcharts;

isHighcharts = typeof Highcharts === 'object';

chartOptions: Highcharts.Options = {
series: [
{
type: 'line',
pointInterval: 24 * 3600 * 1000,
data: [1, 2, 3, 4, 5],
},
],
};
}

line-chart.component.html

<highcharts-chart
*ngIf="isHighcharts"
[Highcharts]="Highcharts"
[constructorType]="'stockChart'"
[options]="chartOptions"

I am facing this issue

ERROR TypeError: Cannot read properties of undefined (reading 'Core/Globals.js')
at HC_Stock (c:/Users/User/source/project/frontend/node_modules/highcharts/modules/stock.js:9:539)
at eval (c:/Users/User/source/project/frontend/projects/projects-landing-page/src/app/components/line-chart/line-chart.component.ts:7:1)
at async instantiateModule (file:///C:/Users/User/source/project/frontend/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50861:9)

, can you please provide an example code that implements SSR in Angular version 17 using standalone components or how can i fix this ?

node : v20.11.0
angular:17.1
npm 10.4.0

@karolkolodziej
Copy link
Contributor

HI @borisdaev!

From Angular 17 SSR behaves differently than it used to with Angular Universal.
I've used the isBrowser flag instead of the isHighcharts, besides that it is business as usual.

Please see a standalone SSR component in the demo.

Internal note:
Let's improve the documentation and describe SSR in Angular 17.

@borisdaev
Copy link
Author

Thank you for the demo code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants