This repository has been archived by the owner on Oct 4, 2022. It is now read-only.
Try out react-tag-cloud for prominent wordcloud #307
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
As requested in https://github.com/Yoast/wordpress-seo-premium/issues/2297, we investigated the usability of react-tag-cloud for creating a word-cloud to visualise prominent words. While reasonably plug-and-play in theory, there is some behaviour that should be fixed which may cost more time than is desirable for a feature this size (see below)
We have created an example in the
apps/components
example-app.The problem: words can be missing from the wordcloud.
When does this happen:
It does not seem trivial to change this behaviour, as it is deeply rooted in the package underlying most wordcloud packages, d3-cloud. On their github page they mention:
As not being able to fit is more likely for longer and larger words, and our most prominent words are the largest (due to font size), we run the risk of not showing that word in the WordCloud. This will be aggravated by our WordCloud having to work in the constrained space of the SideBar, and on mobile devices. Users that speak a language that has longer words will also be encountering the issue more.
Possible solution:
There is a fork of
d3-cloud
(so not the react version we implemented here) that implements an overflow mechanic. I already saw some comments that this fork does not deal with whitespace very nicely, but it might be worthwhile to check out.Test instructions
This PR can be tested by following these steps:
Checkout branch, and in the javascript root, for good measure, run
yarn install && lerna bootstrap
.Go to
.../javascript/apps/components
and runyarn start
.In the browser, go to
localhost:3333
, and click the WordCloud button in the top menu.Play around with the settings here. For a hint of one of the issues with this package: try making the most frequent word quite long, and make the window narrower. At some point the most frequent word will not be included in the cloud.
Package(s) involved:
components
Should the change be included in the package changelog?
Should the change be included in one or more plugin changelogs?
Package changelog item (if applicable):
Added a WordCloud component.
Plugin changelog item (if applicable):
Added a the WordCloud component to the improved internal linking feature.
Impact check
UI changes
Quality assurance
Related to https://github.com/Yoast/wordpress-seo-premium/issues/2297