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

Overlay bug when changing layout size #81

Closed
StefanDimov opened this issue Nov 19, 2015 · 4 comments
Closed

Overlay bug when changing layout size #81

StefanDimov opened this issue Nov 19, 2015 · 4 comments

Comments

@StefanDimov
Copy link

Here is the code that breaks for me - https://gist.github.com/StefanDimov/88a4b2a749c267ab4f78

I want to change the layout size on window resize, so the space will be efficiently used, but sometimes when I shrink the browser's width as much as I can and then expand it some words start to layered on top of others. Doesn't occur consistently, but most of the times it's there.

@Kcnarf
Copy link

Kcnarf commented Dec 14, 2015

We also had an overlay issue when using 'cloudLayout.start()' in a loop, where each loop reduces the fontSize in order to overcome the 'bigger words not appearing' bug (see #36).

It appears that d3-cloud adds some info/attributes to the tags you pass in cloudLayout.words(). Notably, d3-cloud stores the 'x' and 'y' positions of each tag. When iterating, these pieces of information are not removed/refresh/updated. Hence, iteration N re-uses information produced previously, which leads to weird results (ie. overlapping).

We overcome the overlapping issue by manually removing the added information, and passing an array of 'fresh' tags to 'cloudLayout.words()'.

@Kcnarf
Copy link

Kcnarf commented Dec 14, 2015

Also, check the font family:
1- be sure that at line 80, d.font starts with 'lmpact'
2- (not sure) at line 94 use 'Impact' instead of 'impact' (upper case at first char)

@Laobiz
Copy link

Laobiz commented Sep 14, 2016

How did you manage to remove the information manually? @Kcnarf

@GregoryPotdevin
Copy link

In case other people have this problem : we had the issue when running d3-cloud several times with decreasing font sizes until every word fit, every once in a while the layout would look random.
Using const words = cloneDeep(originalWords) fixed the issue (as Kcnarf said, d3-cloud injects some position infos which you'll want to flush)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants