amcharts angular universal amcharts for angular

The solution for “amcharts angular universal amcharts for angular” can be found here. The following code will assist you in solving the problem.

declare var require: any;

@Component({…})
export class MapComponent implements OnInit, OnDestroy {

private chart;
isBrowser: boolean

constructor(
@Inject(PLATFORM_ID) private platformId: Object
) {
this.isBrowser = isPlatformBrowser(platformId)
}

ngOnInit(): void {
if (this.isBrowser) {
this.setUpChart();
}
}

setUpChart() {
if (this.isBrowser) {

const am4core = require(“@amcharts/amcharts4/core”);
const am4maps = require(“@amcharts/amcharts4/maps”);

let chart = am4core.create(“world-map”, am4maps.MapChart);
// …
}
}npm install @amcharts/amcharts4

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in