Skip to content

Commit

Permalink
feat: set constante for number of intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
RoxaneBurri committed Mar 23, 2023
1 parent deb0f3a commit c2a048a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Wordcloud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import {
} from "./utils";
import * as React from "react";

import { CONTAINER_HEIGHT, CONTAINER_WIDTH, DEFAULT_RECT } from "./constants";
import { defaultWords1 } from "./data";
import {
CONTAINER_HEIGHT,
CONTAINER_WIDTH,
DEFAULT_RECT,
NUMBER_OF_INTERVALS,
} from "./constants";

const CUT_OFF = 0.5;

Expand Down Expand Up @@ -46,7 +50,9 @@ const Wordcloud = ({
y: centerY,
};

const weight = [1, 1, 1, 1];
// Initialize the weights with the value 1, of the size of the number of intervals
const weight = new Array(NUMBER_OF_INTERVALS).fill(1);

const newPositions = rectsToPlace.slice(1).reduce(
(placedElements, rect) => {
const futureWord = futurPosition(rect, placedElements, 3, weight);
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export const INTERVAL = {
c: { x: 180, y: 269 },
d: { x: 270, y: 360 },
};

export const NUMBER_OF_INTERVALS = 6;

0 comments on commit c2a048a

Please sign in to comment.