Add word cloud custom weight fucntion

This commit is contained in:
Peter
2021-02-12 10:16:27 +01:00
parent 90d6dfd503
commit 773e3f3dfb
2 changed files with 22 additions and 8 deletions
+20 -6
View File
@@ -69,20 +69,34 @@ export class SearchPage implements OnInit {
wordCloud(){
this.search.mostSeachWord("10").subscribe(res=>{
this.search.mostSeachWord("15").subscribe(res=>{
const container = document.querySelector('.most-searched-word-container');
container.setAttribute('style',`height: ${window.innerWidth}px`);
let list = []
const highest= res[0].Hits;
const lowest = res[res.length-1].Hits;
const range = highest - lowest;
const perPercent = range / 100;
let list = [];
res.forEach(element => {
list.push(Object.values(element))
// minimum font sixe
// Editable -----------------------------------
const minimumSize = 9;
// Change scale
// Editable ------------------------------------
const multiplicator = 0.56;
res.forEach(e => {
const array: any = Object.values(e);
array[1] = (((array[1] - lowest) / perPercent) * multiplicator) + minimumSize;
list.push(array)
});
this.list = list
const elem = document.documentElement.querySelector('.most-searched-word-container');