Reputation: 1
i need to draw a graph chart i have this code referement in .js
loadServizi(servizi => {
loadConcetti(concetti => {
graph = buildGraph(servizi, concetti);
buildChartConcetti(graph);
});
});
in angular i have replicate loadServizi , and loadConcetti that return Observable<Concetti[]> and the same for loadServizi , function buildGraph need this 2 array of Object to drow graph , this is my implementation in angular:
drowChartAngular(): void {
this.concettoService.getConcetti().subscribe(dataConcetti => {
this.concettoService.getServizi().subscribe(dataservice=>{
this.concetti = dataConcetti;
this.servizi = dataservice;
this.graph = this.buildGraph(dataservice, dataConcetti);
});
});
and in buildGraph function :
servizi.forEach(d => {
let idServizio = `${this.DATA_CATEGORY.servizio.id}-${d.id}`;
nodes[idServizio] = {
id: idServizio,
name: d.nome,
category: this.DATA_CATEGORY.servizio.id,
info: this.createServizioInfo(d),
adjNodes: d.dominiInteresse.map(x => `${this.DATA_CATEGORY.concetto.id}-${x.concettoRelativo.id}`)
};
});
at this line "adjNodes: d.dominiInteresse.map(x => ${this.DATA_CATEGORY.concetto.id}-${x.concettoRelativo.id}
)" i have this error in console :
ERROR TypeError: Cannot read properties of undefined (reading 'map')
at DemoComponent.push../src/app/components/demo/demo.component.ts.DemoComponent.createServizioInfo (demo.component.ts:225:71)
at demo.component.ts:110:20
at Array.forEach (<anonymous>)
at DemoComponent.push../src/app/components/demo/demo.component.ts.DemoComponent.buildGraph (demo.component.ts:104:13)
at SafeSubscriber._next (demo.component.ts:67:28)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:196:1)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134:1)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77:1)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54:1)
at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77:
I don't know what can cause it if the map, or the double subscribe
Upvotes: 0
Views: 59