madox2 / react-tagcloud

Tag/word cloud component for react https://madox2.github.io/react-tagcloud/
MIT License
191 stars 31 forks source link

NaN when min and max are same #5

Closed johnsoncze closed 5 years ago

johnsoncze commented 6 years ago

Hi,

when tags contains only tags with same count, calculation of tag size contains division by zero https://github.com/madox2/react-tagcloud/blob/master/lib/tag-cloud.js#L37

Would be nice to return maxSize when min and max are same.

madox2 commented 6 years ago

Hi, thanks for reporting! Maybe the value between minSize and maxSize would be even better. Could you make a PR?

johnsoncze commented 6 years ago

What about something like defaultSize prop that will be used in this case. Or what about don't set size when min and max are same? I will make a PR, but before that I want to discuss it :) Thanks

madox2 commented 6 years ago

I wouldn't add a new prop for such edge case. Setting it to max is alright, but I think max + min / 2 would be a reasonable compromise :)