0

How can I create a Wordcloud using NodeJS without using the browser? The libraries I could find always need the browser to generate.

1 Answers1

0

A question I would ask.. What is the use case where you wouldn't want to display the wordcloud?

The libraries will generally rely on canvas to generate the word cloud so obviously it wont work unless its in the browser. If you are trying to generate something that is saved in an image then you would need a way to tally up each item, maybe in an array with its corresponding 'count' and then at the end print those words to and image with varying font sizes based on their 'count' in the array.

Again, without know the use case its hard to say for sure.

proxim0
  • 1,418
  • 2
  • 11
  • 14
  • The result or the word cloud picture should be generated on the server side in any case and then the image should be output in ASCII format, for example Base64. Use case to generate the wordcloud not browser based is, it should be possible to use the wordcloud picture independent of the browser and the appearance of the wordcloud should not depend on the preferences and the used browser. – TheProgramer Apr 13 '21 at 09:19
  • So doing some searching it does appear node can access canvas without the use of the browser, found this topic on SO that may be helpful as well https://stackoverflow.com/questions/35137936/can-i-let-node-js-generate-a-canvas-without-an-html-page then you could possibly use other packages to save it as a png for viewing or convert to base64 and send it that way – proxim0 Apr 13 '21 at 15:12