angular am4chart.MapChart code example
Example: amcharts angular universal
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);
}
}