Creating a wordcloud

Hello, i'm trying create a wordcloud on retool.

First, i created a stopword list.

Second, i create a query to count words that not inserted on stopwords.

So i get a array with words and quantity, with this query:

SELECT
  LOWER(word) AS word,
  COUNT(*) AS size
FROM
  (
    SELECT
      REGEXP_SPLIT_TO_TABLE(caption, E'\\s+') AS word
    FROM
      ig_other_posts
  ) AS subquery
WHERE
  LOWER(word) NOT IN (
    SELECT
      LOWER(word)
    FROM
      stopwords
  )
GROUP BY
  word
ORDER BY
  size DESC
LIMIT
  100;

Great. To show wordcloud, i'm trying to follow this topic:

But not success.

On anyChart docs, i've founded this guide:

Looks like a way to construct.

Now, i inserted https://cdn.anychart.com/releases/8.11.1/js/anychart-core.min.js and https://cdn.anychart.com/releases/8.11.1/js/anychart-tag-cloud.min.js modules on js.

And inserted a HTML module with this code:

And trying to insert js code:

 anychart.onDocumentLoad(function () {
  
 data: [
        ["Chocolate", 5],
        ["Rhubarb compote", 2],
        ["Crêpes Suzette", 20],
        ["American blueberry", 2],
        ["Buttermilk", 7]
    ]

      // create an instance of a pie chart
       var chart = anychart.pie();
       window.Retool.subscribe(function(model) {
              
      // set the data
        chart.data(model.data);
      // set chart title
      chart.title("Top 5 pancake fillings");
      // set the container element 
      chart.container("container");
      // initiate chart display
      chart.draw();
    })

});

What's the next step? Because app remains blank.

(I know that the date should be from my query, but even with that fixed date it is not showing anything)

Thanks!

Where did you add the js libs?

I tried it in two different places.

First, I tried it in the HTML module itself, with the tags and all. Then I tried in the app settings, in "add lib"

I just got it using CUSTOM COMPONENT instead of HTML.

Putting the word model in DATA and the code in IFRAME CODE.

Is it the best approach?

1 Like

I was about to suggest the very same thing. Glad you got it worked out!

2 Likes