anHALytics / anHALytics-frontend

Frontend interfaces suited for anHALytics API (in development)
3 stars 1 forks source link

Word cloud, font size and positionning #57

Open kermitt2 opened 7 years ago

kermitt2 commented 7 years ago

I changed the word cloud to take into account keyword frequency by scaling the font size (linear scaling). However, there are some issues with the positioning, because the dimension of cloud cannot be known in advance nor its the position in the svg canvas.

So before it was like that, same font size for all key words (17px): screenshot from 2016-11-28 05-43-41

Now, in general it's ok, but there's often some empty space between the inner g element and the svg canvas size that should be removed (maybe by looking at the position of the words): screenshot from 2016-11-28 05-19-07

It happen that for the same set of words, it can be quite good: screenshot from 2016-11-28 05-21-30

Or bad with cut words: screenshot from 2016-11-28 05-23-49

Note that for avoiding large words to be removed by the d3.cloud algorithm (see https://github.com/jasondavies/d3-cloud/issues/36), I've a bit enlarged the cloud size as compared to the svg canvas size. It's a decent compromise, but some cut words can happen from time to time. Ideally I think the cloud size should not be enlarged, but the cloud should be translated in the svg canvas in a more case-to-case manner by looking at the position of the words, and the size of the svg canvas should be adjusted to the one of the inner g element.

Aazhar commented 7 years ago

c17b26a

kermitt2 commented 7 years ago

Most likely better to move to another more reliable and predictable word cloud library. The one of Kibana looks very nice. See https://github.com/elastic/kibana/tree/master/src/core_plugins/tagcloud https://github.com/elastic/kibana/pull/8104