diff --git a/src/App.tsx b/src/App.tsx index 2f01499..45fb0f3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -40,6 +40,7 @@ const Wordcloud = () => { let weight = [0, 0, 0, 0]; const newPositions = rectsToPlace.slice(1).reduce( (placedElements, rect) => { + console.log(weight); // move the word const futurePositionWord = futurPosition( rect, diff --git a/src/utils.ts b/src/utils.ts index 5d15481..ef301e1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -124,7 +124,8 @@ export const placeWordOnOuterCircle = ( const randomInter = randomInterval(0, Math.max(...cumulativeWeight)); const inter = cumulativeWeight.findIndex((el) => el > randomInter); - weight[inter] += 1; + weight[inter] = weight[inter] + 1; + console.log(weight); let angleInter = { x: 0, y: 360 }; @@ -173,10 +174,12 @@ export const futurPosition = ( weight: number[] ): FuturPosition => { let isCollision = false; - console.log(weight); + // console.log(weight); // put the word in random place around the parent - let movedWord = placeWordOnOuterCircle(word, passRect, weight).rect; + const move = placeWordOnOuterCircle(word, passRect, weight); + let movedWord = move.rect; + weight = move.weight; let iter = 0; let displacement = 0; do {