From e4c4c6d03ddd49f191ad1acb48b44502038be058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Romaszkin?= Date: Fri, 26 Jun 2020 02:55:32 +0200 Subject: [PATCH] Fix graph disappearing --- .../main-view/visualize-forum/visualize-forum.component.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main-view/visualize-forum/visualize-forum.component.ts b/frontend/src/app/main-view/visualize-forum/visualize-forum.component.ts index 822bb08..e0e97ca 100644 --- a/frontend/src/app/main-view/visualize-forum/visualize-forum.component.ts +++ b/frontend/src/app/main-view/visualize-forum/visualize-forum.component.ts @@ -4,6 +4,7 @@ import { OnDestroy, ViewChild, ElementRef, + AfterViewInit, } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { GetVisualizationDataService } from '../../_services/get-visualization-data.service'; @@ -18,7 +19,7 @@ import maked3hierarchy from '../../_functions/maked3hierarchy'; templateUrl: './visualize-forum.component.html', styleUrls: ['./visualize-forum.component.scss'], }) -export class VisualizeForumComponent implements OnInit, OnDestroy { +export class VisualizeForumComponent implements AfterViewInit, OnDestroy { private subscription: Subscription; private data: Post[]; private hierarchizedData: Post[]; @@ -30,7 +31,7 @@ export class VisualizeForumComponent implements OnInit, OnDestroy { private getDataService: GetVisualizationDataService ) {} - ngOnInit(): void { + ngAfterViewInit(): void { this.subscription = this.route.params .pipe(concatMap((params) => this.getDataService.getDiscussion(params.id))) .subscribe((result) => { @@ -59,7 +60,7 @@ export class VisualizeForumComponent implements OnInit, OnDestroy { const element = this.treeContainer.nativeElement; /* Clear previous graph */ - d3.select(element).select('svg').remove(); + d3.select(element).select('svg').empty(); /* Create SVG */ const svg = d3