From 09a097c506d3a93111daed735eda29e667c4802f Mon Sep 17 00:00:00 2001 From: Fabian Gruenwald <fabian.gruenwald@mni.thm.de> Date: Sat, 1 May 2021 16:03:01 +0200 Subject: [PATCH] color fix --- .../shared/tag-cloud/tag-cloud.component.html | 23 ++++++++-------- .../shared/tag-cloud/tag-cloud.component.ts | 26 +++++++++---------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/app/components/shared/tag-cloud/tag-cloud.component.html b/src/app/components/shared/tag-cloud/tag-cloud.component.html index e27a50277..dbd0424a6 100644 --- a/src/app/components/shared/tag-cloud/tag-cloud.component.html +++ b/src/app/components/shared/tag-cloud/tag-cloud.component.html @@ -4,17 +4,18 @@ </ars-row> - <ars-fill ars-flex-box> - - <angular-tag-cloud - [data]="data" - [width]="options.width" - [height]="options.height" - [overflow]="options.overflow" - [zoomOnHover]="zoomOnHoverOptions" - (clicked)="tagClicked($event)" - [log]='"debug"'> - </angular-tag-cloud> + <ars-fill ars-flex-box style="width:100%;height:100%;"> + + <angular-tag-cloud + [data]="data" + [width]="options.width" + [height]="options.height" + [overflow]="options.overflow" + [zoomOnHover]="zoomOnHoverOptions" + (clicked)="tagClicked($event)" + [log]='"debug"'> + </angular-tag-cloud> + </ars-fill> diff --git a/src/app/components/shared/tag-cloud/tag-cloud.component.ts b/src/app/components/shared/tag-cloud/tag-cloud.component.ts index 36108f7c7..64e08d0e9 100644 --- a/src/app/components/shared/tag-cloud/tag-cloud.component.ts +++ b/src/app/components/shared/tag-cloud/tag-cloud.component.ts @@ -9,10 +9,9 @@ import {Result, SpacyService} from "../../../services/http/spacy.service"; import {Comment} from "../../../models/comment"; import {Rescale} from "../../../models/rescale"; -const COLORS: string[] = ["blue", "red", "yellow", "green"] - class TagComment implements CloudData { - constructor(public color: string, + constructor( + public color: string, public external: boolean, public link: string, public position: Position, @@ -22,7 +21,7 @@ class TagComment implements CloudData { public weight: number) { } } - +const COLOR: string[] = ["red", "green", "blue", "yellow", "orange"]; @Component({ selector: 'app-tag-cloud', templateUrl: './tag-cloud.component.html', @@ -45,8 +44,8 @@ export class TagCloudComponent implements OnInit { delay: 0.4 // Zoom will take affect after 0.8 seconds }; - data: CloudData[] = []; + data: CloudData[] = []; constructor(private commentService: CommentService, private spacyService: SpacyService) { @@ -54,7 +53,6 @@ export class TagCloudComponent implements OnInit { } ngOnInit(): void { - this.commentService.getAckComments(this.roomId).subscribe((comments: Comment[]) => { this.analyse(comments) }); @@ -62,19 +60,19 @@ export class TagCloudComponent implements OnInit { analyse(comments: Comment[]) { - const commentsConcatenated = comments.map(c => c.body).join(" ") - console.log(commentsConcatenated) - this.spacyService.analyse(commentsConcatenated, "de").subscribe((res: Result) => { + const commentsConcatenated = comments.map(c => c.body).join(" "); - res.words.forEach(console.log); - res.arcs.forEach(console.log); + this.spacyService.analyse(commentsConcatenated, "de").subscribe((res: Result) => { this.data = res.words.filter(w => w.tag === "NE" || w.tag === "NN" || w.tag === "NMP" || w.tag == "NNE").map(w => - new TagComment(COLORS[0], true, "www.google.com", null, 0, w.text, "comment.creatorId", Math.random()) + + new TagComment(COLOR[Math.floor( + Math.random()*(COLOR.length-1))], + true, null, null, + Math.floor(Math.random()*30-15), w.text, + "todo", Math.floor(Math.random()*10)+1) ) } - - ); } tagClicked(clicked: CloudData) { -- GitLab