Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass the whole words array to mapping functions #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

pass the whole words array to mapping functions #110

wants to merge 1 commit into from

Conversation

stegben
Copy link

@stegben stegben commented Nov 11, 2016

I would like to pass a custom fontSize mapper like this:

function fontSizeMapper (word, idx, words) {
  const max = 100;
  const min = 10;
  const wordSize = words.map(w => w.size);
  const minSize = Math.min(...wordSize);
  const maxSize = Math.max(...wordSize);
  return min + (max - min) * (word.size - minSize) / (maxSize - minSize);
};

It's a normalization of font sizes, which requires to know the min and max value of word counts.

@jasondavies jasondavies added the req label Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants