I am trying out swimlane ngx-graph, in my application user can delete or add nodes. Based on delete or add action I will update my data accordingly.
Real question now is how can I refresh my graph without refreshing entire page.
I am trying out swimlane ngx-graph, in my application user can delete or add nodes. Based on delete or add action I will update my data accordingly.
Real question now is how can I refresh my graph without refreshing entire page.
You can update it by using the update$
option of the graph,
HTML :
<ngx-graph
. . . // Other options
[update$]="update$"
. . .
>
TS :
// Observable for update
update$: Subject<any> = new Subject();
// Update function
updateChart(){
this.update$.next(true);
}
Once you update your data, call updateChart()
For people getting 'Cannot assign to 'data' because it is an import.'
using Thanan_Jajes answer, the following worked for me:
Object.assign(this, {data: [...data]});
you trying to modify data is not recognized by change detection.
this.data = updatedData;
instead try spreading data over, that will detect the changes. It worked for me.
this.data = [...updatedData];