From b5d53ee13f0c262bd2e14a04ef34213e5f795fc0 Mon Sep 17 00:00:00 2001 From: xiaowen <372193233@qq.com> Date: Wed, 31 Aug 2022 17:07:19 +0800 Subject: [PATCH] cxw-010203 --- components/word-cloud/index.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/components/word-cloud/index.js b/components/word-cloud/index.js index d7a6e91..2684aa7 100644 --- a/components/word-cloud/index.js +++ b/components/word-cloud/index.js @@ -120,21 +120,35 @@ Component({ } = event.currentTarget.dataset this.triggerEvent('detail', detail); }, - doData(list = []) { - if (list.length === 0) { + doData(arr1 = []) { + if (arr1.length === 0) { return [] } + let list = this.doList(arr1); let arr = []; let maxVal = list[0][1]; + let minVal = list[list.length - 1][1]; let l = list.length; let x = l / (375 * this.data.height) - let max = x * maxVal; - let y = 23 / max; + let fx = Math.sqrt(x); + let max = fx * maxVal; + let fy = maxVal / minVal; + let fz = fy * 100 >= 500 ? 500 : fy*100; + let y = fz/ max; list.forEach(ele => { - let a = [ele[0], ele[1] * x * y]; + let a = [ele[0], ele[1] * x * y ]; arr.push(a) }) return arr; + }, + doList(arr = []) { + let list = []; + if(arr.length > 140) { + list = arr.slice(139) + } else { + list = arr; + } + return list } } }) \ No newline at end of file